我的mac osx与python 2.7.10
一起工作正常,我通过python3
安装了brew install python3
。
在我的bash_profile
上,然后创建alias python=python3
。
但是当我
>>python3
我得到了:
Your PYTHONPATH points to a site-packages dir for Python 2.x but you are running Python 3.x!
PYTHONPATH is currently: "/usr/local/lib/python2.7/site-packages:"
You should unset PYTHONPATH to fix this.
然后我运行brew uninstall python3
,但事情没有进入以前的配置,我再也无法运行python
版本。
>>python
现在给了我:
-bash: python3: command not found
然后我尝试brew link python3
,因为它似乎在那里,但无济于事。
现在,如果我which python
,我得到:
/usr/local/bin/python
。
我如何解决这个混乱问题,我想保留2.7和3.5?
PS。我的bash_profile现在:
export PATH=“/usr/local/bin:/usr/local/sbin:/usr/bin:~/bin:./bin:$PATH"
"export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH"
答案 0 :(得分:0)
尝试手动设置PYTHONPATH
环境变量以指向正确的python安装。如果您想要两者,请将其设置为两者(以;
分号分隔),然后在cmd python2
或python3
中指定,具体取决于您要打开的内容。
这解释了如何访问OSX上的环境变量:
Setting environment variables in OS X?
抱歉,我提供了更多详细信息,但我只在家用机器上运行Linux和Windows,因此我对OSX了解不多。
编辑:实际上,您可能需要使用,
逗号分隔不同的位置,而不是分号。不知道,看看现有的,看它是怎么回事。