如何在Mac上为2.7设置python路径? [英] How to setup python path for 2.7 on mac?

查看:426
本文介绍了如何在Mac上为2.7设置python路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,这个问题已经被问过很多次了。但是,我仍然无法摆脱这一点。我在Mac上找到了以下信息。

I am aware that, this question has been asked and answered many times. But, still i couldn't get rid of this. I found out the following info on my mac.

cd /Library/Frameworks/Python.framework/Versions/
Current -> 2.7
3.6

whereispython
/usr/bin/python

which python
/usr/bin/python

which -a python
/usr/bin/python
/usr/bin/python

python
Python 2.7.10 (default) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

即使我编辑〜/ .bash_profile 如下

# Setting PATH for Python 2.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

#PYTHONPATH
PYTHONPATH="${PYTHONPATH}:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python"
export PYTHONPATH

然后,源〜/ .bash配置文件。重新启动Mac&之后终端,仍然可以看到 / usr / bin / python 而不是指向 / Library /../ Python2.7 当执行哪个python 时。

Then, source ~/.bash-profile. After restarting my mac & terminal, could see still /usr/bin/python instead of pointing to /Library/../Python2.7 when executed which python.

我卸载了python,然后重新安装了 pip install python
而且,我还能看到python安装在 /System/Library/Frameworks/Python.framework/Versions

I uninstalled python and re-installed "pip install python" And also, i could see python installed under /System/Library/Frameworks/Python.framework/Versions

2.6
2.7
2.5 -> 2.6
2.3 -> 2.6
Current -> 2.7

我不确定这里可能缺少什么。如何在Mac中设置/添加python路径?请帮助我理解和克服这一点。您能在这里帮我吗?

I am not sure what could be missing here. How can i set/add the python path in mac ? Please help me to understand and overcome this. Can you please help me here ?

参考将python路径添加到mac osx

推荐答案

通过brew安装。 简单安装python2或python3
brew自动在Mac中设置python路径。

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

这篇关于如何在Mac上为2.7设置python路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆