[英]Unable to use easy_install to install Python modules
我正在尝试使用easy_install
通过执行安装名为请求的模块
easy_install requests
一周前,当我使用Python 2.6.5时,此方法运行良好,但今天,我安装了Python 2.7.2,然后尝试在我的一个脚本中import requests
,但失败了。 然后,我尝试使用easy_install requests
重新安装请求,但收到此错误
install_dir /usr/local/lib/python2.6/dist-packages/
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/usr/local/lib/python2.6/dist-packages/test-easy-install-15207.pth'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python2.6/dist-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
http://packages.python.org/distribute/easy_install.html
Please make the appropriate changes for your system and try again.
因此,我被告知要重新安装easy_install,然后我去了http://pypi.python.org/pypi/setuptools ,得知我必须
首先从系统的site-packages目录(和任何其他sys.path目录)中删除所有setuptools * .egg和setuptools.pth文件。
所以我做到了。 然后,我从setuptools-0.6c11-py2.7.egg
重新安装了setuptools-0.6c11-py2.7.egg
。 似乎成功了,但是当我运行easy_install requests
时,除了目录python2.6 / dist-packages现在是python2.7 / site-packages外,我基本上遇到了相同的错误
siddhion@siddhion-laptop:~$ easy_install requests
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/test-easy-install-16253.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/local/lib/python2.7/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
http://peak.telecommunity.com/EasyInstall.html
Please make the appropriate changes for your system and try again.
另外,当我执行easy_install
并按tab时,我会获得以下选项
easy_install easy_install-2.6 easy_install-2.7
easy_install-2.6为何出现?
和
如何使易安装的产品再次工作?
您是否尝试过像这样使用sudo
?
sudo easy_install requests
或将安装目录指定为您具有写特权的目录。
easy_install --install-dir=/home/foo/bar
但是您应该真正使用PIP而不是easy_install
。 它要好得多,并具有更多功能。
您应该在基于软件包的Linux发行版上使用virtualenv
,这样Python脚本就不会干扰其他软件包或与操作系统的软件包管理器冲突。
以下对我有用的Ubuntu 12.10安装easy_install然后pip :
sudo apt-get install python-virtualenv
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python get-pip.py
您是否尝试过将新的python.framework添加到path? 在山狮上,我将/Library/Frameworks/Python.framework/Versions/3.3/bin/
添加到/etc/paths
,然后可以使用easy_install-3.3和pip-3.3
在easy_install
之前使用Sudo
可能会解决您的问题
Sudo easy_install requests
谢谢
这可能是您在前面缺少“ sudo”的简单情况。 您可以使用sudo简易安装请求尝试吗
放置“ sudo”将添加所需的权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.