【发布时间】:2015-06-22 18:22:03
【问题描述】:
我在 OSX 上,通过 virtualfish 设置了一个名为 ds-mapreduce-env 的 python virtualenv。在我的项目目录中激活venv 后,看起来就像选择了正确的pip 和python:
~/d/ds-mapreduce (venv) master ➜ which pip
/Users/cody/.virtualenvs/ds-mapreduce-env/bin/pip
~/d/ds-mapreduce (venv) master ➜ which python
/Users/cody/.virtualenvs/ds-mapreduce-env/bin/python
但是当我运行pip install 时,它并没有按预期安装到虚拟环境中。但是,当我使用 sudo 时,它确实如此。
~/d/ds-mapreduce (venv) master ➜ pip install geonamescache
Requirement already satisfied (use --upgrade to upgrade): geonamescache in /usr/local/lib/python2.7/site-packages
~/d/ds-mapreduce (venv) master ➜ sudo pip install geonamescache
The directory '/Users/cody/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/cody/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting geonamescache
Installing collected packages: geonamescache
Successfully installed geonamescache-0.18
我猜这是某种权限问题,但我想不通。我安装了python 和brew install python 和virtualfish 和pip install virtualfish。我尝试删除并重新安装没有效果。
我的解决方案
我的问题是我的PYTHONPATH。我的PYTHONPATH 前面有/usr/local/lib/python2.7/site-packages。删除它可以解决问题!
【问题讨论】:
-
您是否以 root 身份创建了 virtualenv? (root是否拥有文件夹“/Users/cody/.virtualenvs/ds-mapreduce-env”)
-
不以root身份:
drwxr-xr-x 7 cody staff 238B Jun 22 12:23 ds-mapreduce-env -
嗨科迪。我在这里的回答是否有助于解决您的问题?
标签: python pip virtualenv sudo fish