python-guide icon indicating copy to clipboard operation
python-guide copied to clipboard

python 3 setup slightly incorrect for OSX High Sierra

Open bnorquist opened this issue 6 years ago • 7 comments

When using brew install python and adding export PATH=/usr/local/bin:/usr/local/sbin:$PATH to your .profile python still points to the system python executable. Instead you have to add this to the .profile: export PATH="/usr/local/opt/python/libexec/bin:$PATH".

I created a local branch on my computer with this edit but it is saying I don't have permissions to push it. I did a good amount of googling to get this set up so figured I would try to save others the time in the future :)

see first comment on this SA thread: https://stackoverflow.com/questions/5157678/python-homebrew-by-default/48101303#48101303

bnorquist avatar Mar 22 '18 04:03 bnorquist

Fork the repository and ask for a Pull Request !! 😄

https://help.github.com/articles/fork-a-repo/

https://help.github.com/articles/creating-a-pull-request/

mnunezdm avatar May 12 '18 17:05 mnunezdm

Please send a pull request!

kennethreitz avatar May 13 '18 17:05 kennethreitz

done :D https://github.com/kennethreitz/python-guide/pull/898

bnorquist avatar May 14 '18 03:05 bnorquist

@bnorquist I was having a similar problem, but followed the instructions in the note in this section of the documentation:

If pipenv isn’t available in your shell after installation, you’ll need to add the user base‘s binary directory to your PATH.

On Linux and macOS you can find the user base binary directory by running python -m site --user-base and adding bin 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 your PATH. You can set your PATH permanently by modifying ~/.profile.

When I run python -m site --user-base, I get /Users/charliesneath/Library/Python/3.6. I added the following to ~./profile:

export PATH="~/Library/Python/3.6/bin"

and this fixed this issue I was having not being able to run pipenv.

Is this related to the fix you found above?

charliesneath avatar May 25 '18 02:05 charliesneath

Realized this is mentioned in #840 by @chsm in his comment.

charliesneath avatar May 25 '18 03:05 charliesneath

See https://github.com/realpython/python-guide/issues/960 for a bit more discussion.

apjanke avatar Dec 18 '18 07:12 apjanke

and this fixed this issue I was having not being able to run pipenv.

Hi! Even if you could run pipenv, the documentation of pipenv discourages the installation with brew install pipenv:

Homebrew installation is discouraged because each time the Homebrew Python is upgraded, which Pipenv depends on, users have to re-install Pipenv, and perhaps all virtual environments managed by it.

AucaCoyan avatar Mar 05 '22 19:03 AucaCoyan