Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixing PATH for Python libraries using Bash

I am attempting to install some Python libraries by executing variations of the following command in Bash:

pip install --user -U numpy 

I installed Python3 using Homebrew.

I then get variations of the following message each time:

WARNING: The scripts f2py, f2py3 and f2py3.7 are installed in '/Users/x/Library/Python/3.7/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.

How can I fix this issue to avoid problems in the future?

like image 667
The Pointer Avatar asked Sep 22 '19 16:09

The Pointer


People also ask

Where is my Python path Linux?

If you are using the standard flavour of Linux, open up the bash shell and type the following phrase, export PATH=”$PATH:/usr/local/bin/python” and press Enter. If you have access to either sh or ksh shell, then open up the terminal and type the following, PATH=”$PATH:/usr/local/bin/python” and press Enter.


1 Answers

The error message is telling you to add Python 3 to your path.

To do that, use a text editor to open /Users/<you>/.profile, and as the very last line add:

export PATH=/Users/<you>/Library/Python/3.8/bin:$PATH 

Then you'll need to launch a new Terminal window for those settings to take effect. (you could make it take effect in your current shell by entering the line directly into your shell)

[Edit: now that Python 3 has become the official version of Python, it's likely been promoted to /usr/bin, and is likely already on your path. If you'd like your Homebrew version of Python to override the system's version, do the same EXPORT PATH trick, but with the path to Homebrew instead (/usr/local/bin, or /opt/local/bin)]

like image 99
Dylan McNamee Avatar answered Sep 20 '22 06:09

Dylan McNamee