python-guide
python-guide copied to clipboard
Potential for confusion on Pipenv & Virtual Environments
I arrived on the Pipenv & Virtual Environments
page from Installing Python 3 on Mac OS X
. At that point, I've have installed python2 and python3 via homebrew and there is also the system python. Installing Python 3 on Mac OS X
clearly states that
Working with Python 3 At this point, you have the system Python 2.7 available, potentially the Homebrew version of Python 2 installed, and the Homebrew version of Python 3 as well.
$ python will launch the system Python interpreter.
$ python2 will launch the homebrew-installed Python 2 interpreter (if any).
$ python3 will launch the homebrew-installed Python 3 interpreter.
And yet on Pipenv & Virtual Environments
the first thing I'm encouraged to do is make sure python3 is installed by typing $python --version
which will display the system Python interpreter version.
This could potentially confuse a new developer who may be wondering why they are seeing version say 2.7.x
instead of 3.6.x
as the writeup suggest. Besides as at the time of writting there are not many OS's that have $python
defaulting to version 3.6.x
.
If the writeup in insisting of starting Python 3 with the command $python
then it needs to be explained how this can be done safely.
Thanks.
This part of the guide says that it's written for 3, but will work fine with 2.
@kennethreitz:
I'm not sure that's the issue.
Let's say we have a brand new installation of macOS (i.e. we only have a system installation of Python 2.6.x or 2.7.x) and we want to install Python 3. We go here and follow your instructions:
$ brew install python3
The new Python 3 installation will live wherever Homebrew installed it, and we can access that Python 3 and Pip installation by running python3
and pip3
:
$ which python3
/usr/local/bin/python3
$ which pip3
/usr/local/bin/pip3
Then, we move onto the virtual environments page...
We are told to check to make sure we have Python and Pip installed by running python --version
and pip --version
...
But the problem is, those commands are going to reference the system Python installation and there will be no system Pip installed:
$ which python
/usr/bin/python
$ which pip
=> # no output
I think the issue which @thepreacher is trying to report, and which had me scratching my head tonight as well, is the mismatch between the instructions given and the actual commands necessary to complete them on a macOS system which uses your suggested Python installation method.
Also, not sure if this should be in a separate issue or not, but after following the Homebrew installation instructions, USER_BASE
is actually ~/Library/Python/3.6
, so it might be useful to point out that Mac users will need to export $HOME/Library/Python/3.6/bin
to their path, as the ~/.local
bit only applies on Linux. Gosh-darn Apple has to ruin everything with their non-standard system hierarchy!
This is confused me too on Mac