Reputation: 2039
I'm following these instructions on installing Python 3 with with Homebrew on my MacBook running Mac OSX High Sierra.
I'm having trouble with this step:
Once you’ve installed Homebrew, insert the Homebrew directory at the top of your PATH environment variable. You can do this by adding the following line at the bottom of your ~/.profile file
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
After updating ~/.profile
and running python --version
, I still see Python 2.7.10
.
This seems to be an issue because when I follow the next page to install a virtual environment using pip install --user pipenv
, I get the following warning after installation completes:
The scripts pewtwo, pipenv and pipenv-resolver are installed in '/Users/charliesneath/Library/Python/2.7/bin' which is not on PATH.
It seems like my system is not properly prioritizing Homebrew's installation of Python 3.
How can I fix this?
Upvotes: 5
Views: 2135
Reputation: 4014
For Mac, when you install python3, it is installed in a different path as those examples you are citing. To find out where the python3 is installed, type the command line:
which python3
It will return /Library/Frameworks/Python.framework/Versions/3.6/bin/python3
.
Add the following lines to .bash_profile:
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
Upvotes: 2
Reputation: 2039
I solved this once I eventually understood the following instructions:
If
pipenv
isn’t available in your shell after installation, you’ll need to add the user base‘s binary directory to yourPATH
.On Linux and macOS you can find the user base binary directory by running
python -m site --user-base
and addingbin
to the end. For example, this will typically print~/.local
(with~
expanded to the absolute path to your home directory) so you’ll need to add~/.local/bin
to yourPATH
. You can set yourPATH
permanently by modifying~/.profile
.
My system outputs /Users/charliesneath/Library/Python/3.6
when running the command, so I added the following to ~/.profile
:
export PATH="~/Library/Python/3.6/bin"
Does anyone know why my system is not outputting ~/.local
as suggested by the instructions above?
EDIT: It seems like version of Python I've installed is considered "framework build," and according to the Python documentation, the path I added to ~/.profile
is the default "user base directory" for this framework:
site.USER_BASE: Default value is ~/.local for UNIX and Mac OS X non-framework builds, ~/Library/Python/X.Y for Mac framework builds, and %APPDATA%\Python for Windows.
Upvotes: 0