What is the best way of installing Python's scientific libraries in MacPorts?

Christopher Jones jonesc at hep.phy.cam.ac.uk
Mon Oct 4 20:57:15 UTC 2021



> On 4 Oct 2021, at 9:18 pm, Artemio González López via macports-users <macports-users at lists.macports.org> wrote:
> 
>> 
>> On Oct 4, 2021, at 4:24 PM, Giuseppe 'ferdy' Miceli <ferdy at ferdy.it <mailto:ferdy at ferdy.it>> wrote:
>> 
>> ciao artemio,
>> 
>>> Hi, Giuseppe,
>> 
>> <omissis>
>> 
>>> So my questions are:
>>> 
>>> 1. Should I activate python39 and decativate python37 before installing the 3.9 versions fo numpy, scipy and matplotlib?
>> 
>> I would daresay to remove everything (—force option would be handy) and then start over again from scratch :-)
>> 
>>> Can both be active at the same time after that, or should I keep 3.7 inactive for good (or unistall it)?
>> 
>> you can have python37 and python39 both installed and active and choose with port select which one to use as python3 default version.
>> 
>> wabi:macports-ports admin$ port installed python3\*
>> The following ports are currently installed:
>>   python3_select @0.0_2 (active)
>>   python37 @3.7.12_0+optimizations (active)
>>   python39 @3.9.7_0+optimizations (active)
>> wabi:macports-ports admin$ port select --list python3
>> Available versions for python3:
>> 	none
>> 	python37
>> 	python38-apple
>> 	python39 (active)
>> wabi:macports-ports admin$
>> 
>> nevertheless imho, being your first try with macports, i would suggest to choose one version and have it working with a specific version.
>> you will always have time to experimenting with more than one version.
>> 
>>> 2. Should I install (say) py-numpy or more specifically py39-numpy?
>> 
>> from macports perspective that is the same port (more specifically py39-numpy is a subport of py-numpy.
>> thus if you install py-numpy you shall end up with py39-numpy.
>> 
>>> 3. Is it OK if the 3.7 versions of the py-* package are active throughout this installation process (and afterwards), or should I also deactivate them?
>> 
>> as i mentioned before i would deactivate/uninstall the python37 versions just to be double sure.
>> 
>>> 4. Will "jupyter notebook” automatically find the scientific libraries I’m going to install, or should I do something else (like, e.g., create an environment)?
>> 
>> apologies, on this one i have to surrender since in this case it’s me not coming from math :-)
>> 
>> my experience with macports makes me think it should work out of the box, yet that is really above my paygrade. sorry
>> 
>>> Again, I apologize for my ignorance (I’m coming from Mathematica, but I would like to try python out because many of my colleagues now use it).
>> 
>> absolutely no need to apologize! i am sure if i were coming with silly questions on math you would do your best to help me out ;-)
>> 
>> cheers,
>>>> ferdy
> 
> Ciao Giuseppe,
> 
> I am happy to report that after following your advice everything worked as advertised. I only experienced a very minor glitch, namely that for some reason (probably a minor bug?) the /opt/local/Library/Frameworks/Versions/3.9/bin directory where jupyter resides is not in the $PATH, so you must add it by hand if you want to invoke (say) jupyter with just its name.

No, that is not a bug but intentional. it is that way because in principle you could have multiple versions installed, for different python versions. For that reason one specific python version cannot place its binaries under the default ${prefix}/bin with the nominal names, as that would prevent others from then being installed.

The port does in fact install binaries, but they are suffixed with the python version

Oberon ~/Projects/MacPorts/ports > port contents py39-jupyter_client | grep bin
  /opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/jupyter-kernel
  /opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/jupyter-kernelspec
  /opt/local/Library/Frameworks/Python.framework/Versions/3.9/bin/jupyter-run
  /opt/local/bin/jupyter-kernel-3.9
  /opt/local/bin/jupyter-kernelspec-3.9
  /opt/local/bin/jupyter-run-3.9


so to run a specific version (for a given python version) run XYZ-3.9 etc.

Chris


> 
> Thanks a lot for your patience and help!
> 
> Artemio
> 
> 
> Artemio Gonzalez Lopez
> artemiog at mac.com <mailto:artemiog at mac.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20211004/3c4e8073/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1930 bytes
Desc: not available
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20211004/3c4e8073/attachment.bin>


More information about the macports-users mailing list