I am using Linux Mint 21.2 and I installed numpy using pip: pip install numpy. I got the following message:
Defaulting to user installation because normal site-packages is not writeable
Collecting numpy
Downloading numpy ...
Installing collected packages: numpy
WARNING: The script f2py is installed in '/home/***/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.26.2
I then checked python3 -m pip list -v and almost all packages are in /usr/lib/python3/dist-packages. The location of numpy is /home/***/.local/lib/python3.10/site-packages pip.
What does this mean? I don't even know what f2py is. Did I do something wrong? I was in some random directory in /home/***/. Should I be in a specific directory when I do pip install some-library? And can I somehow move numpy to /usr/lib/python3/dist-packages because all other packages seem to be there?
It's installed as part of NumPy. The reason why NumPy has it is that many of NumPy's linear algebra routines are written in Fortran, and f2py provides a foreign function interface to call them. It's also installed in case you want to call your own Fortran code from Python. You can learn more about this from the NumPy manual.
As for the warning: some Python packages are used as stand-alone command line tools, not just as part of a Python program. The program f2py is one of these. Normally, you would type
f2pyat the terminal, and that will run f2py. However, since the directory pip is installing these to is not on your $PATH, this will not work.You could do one of two things:
Decide that you don't care about using f2py. NumPy will still work correctly, but you cannot add any new Fortran code.
Add pip's
.local/bindirectory to your $PATH. Here's a link to an answer explaining how to do this for Bash on Linux. https://stackoverflow.com/a/74751638/530160If you are using a different shell, like Zsh, you will need to edit a different file.