我使用 brew install python
安装了Python。
which pip
/usr/local/bin/pip
我的PYTHONPATH
显示为/usr/local/lib/python2.7/site-packages/
然而,当我尝试使用pip安装一些东西时,它会去到如下所示的/bin/
目录。我希望安装到/usr/local/lib/python2.7/site-packages/
中。我该如何解决这个问题?
pip install virtualenv
Downloading/unpacking virtualenv
Downloading virtualenv-1.11.6-py2.py3-none-any.whl (1.6MB): 1.6MB downloaded
Installing collected packages: virtualenv
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/commands/install.py", line 283, in run
{....}
File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/_vendor/distlib/util.py", line 384, in write_binary_file
with open(path, 'wb') as f:
IOError: [Errno 13] Permission denied: '/bin/virtualenv'
$ pip list
pip (1.5.6)
setuptools (5.4.2)
wsgiref (0.1.2)
$pip show setuptools
---
Name: setuptools
Version: 5.4.2
Location: /usr/local/lib/python2.7/site-packages/setuptools-5.4.2-py2.7.egg
Requires:
pip已经将基本包安装到site-packages中。然而,运行完全相同的pip以安装virtualenv会尝试安装到/bin/。
pip install flask
)安装flask,它将其安装到/lib/python2.7/site-packages/,而不是/usr/bin/etc....当我执行另一个pip list
时,它只显示上面的内容。对于sudo pip install flask
和之后的pip list
也是一样。没有出现flask。 - imagineerThatbrew doctor
的输出,并将所有与 Python 相关的内容添加到你的问题中吗? - cel