PIP安装和Python路径 [英] PIP install and Python path
问题描述
我正在Mac上使用pip install来获取Django网站的python要求.
I am using pip install on a mac to get my python requirements for a django website.
我从MacPorts获得了点子
I got pip from MacPorts
port install pip-2.7
现在的问题是pip将软件包安装在我的python sys.path不在的位置.
Now the problem is the pip installs the packages in a location which is not in my python sys.path.
我刚刚复制了这个伪造的位置
I just copied this bogus location
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/)
到我的sys.path中存在的位置
to a location present in my sys.path
/Library/Python/2.7/)
当然可以,但是将来我会使用pip,所以我需要一个持久的解决方案.
Of course this worked ok, but I will use pip in the future so I need a persistent solution.
问题是我该如何更改sys.path以识别该废话位置,或者如何告诉pip在其他位置安装依赖项?
The question is how can I alter my sys.path to recognize that crap location or how do I tell pip to install dependencies somewhere else ?
推荐答案
几次尝试后,设置PYTHONPATH环境变量即可.
After a few attempts, setting the PYTHONPATH environmental var worked.
达到此目的的最佳方法是在〜/.bash_profile中添加以下内容:
Best way to achieve this is to add the following to the ~/.bash_profile:
export PYTHONPATH=<bogus path here>
别忘了更改后打开新终端.
Don't forget to open a new terminal after changing.
这篇关于PIP安装和Python路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!