How to setup python path for 2.7 on mac?

我的梦境 提交于 2019-12-05 15:39:25

If you have multiple versions of Python installed on your computer there should be multiple binaries in /usr/bin for each one

MacBook-Pro:~ ak47$ ls /usr/bin | grep python
> python
> python2.6
> python2.7

You can access each different interpreter by changing the trigger

"Explicit is better than implicit"

MacBook-Pro:~ ak47$ python --version
> Python 2.7.10

MacBook-Pro:~ ak47$ python2.6 --version
> Python 2.6.9

MacBook-Pro:~ ak47$ python2.7 --version
> Python 2.7.10

MacBook-Pro:~ ak47$ python3 --version
> Python 3.5.2

Install via brew. brew install python2 or python3. brew sets the python path in mac automatically.

Indeed, as mentioned, installing an up-to-date version of python using Brew is probably the best way to proceed, but be aware that starting with python 2.7.13 Homebrew doesn't add that version of python to your path automatically. It warns you that you must add "export PATH="/usr/local/opt/python/libexec/bin:$PATH"" to your .bash_profile. Do that and everything will work as expected.

From the current directory you want to add in your python path

export PYTHONPATH=$PYTHONPATH:`pwd`
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!