无法使用easy_install安装Python模块
我正在尝试使用 easy_install
来安装一个名为 requests 的模块,
easy_install requests
一周前我使用 Python 2.6.5 时工作正常,但今天我安装了 Python 2.7.2然后尝试在我的一个脚本中导入请求,但失败了。然后我尝试使用 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 并了解到我必须这样做
删除您的所有 setuptools*.egg 和 setuptools.pth 文件 系统的 site-packages 目录(以及任何其他 sys.path 目录) 首先。
所以我就这么做了。然后,我从 setuptools-0.6c11-py2.7.egg 重新安装了 setuptools。它看起来很成功,但是当我运行 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 怎么会在那里?
以及
如何让简易安装再次正常工作?
I am trying to use easy_install
to install a module called requests by doing
easy_install requests
This worked fine a week ago when I was using Python 2.6.5 but today I installed Python 2.7.2 and then tried to import requests
in one of my scripts but it failed. I then tried reinstalling requests with easy_install requests
but got this error
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.
So I was told to go reinstall easy_install and I went to http://pypi.python.org/pypi/setuptools and learned I had to
delete all setuptools*.egg and setuptools.pth files from your
system's site-packages directory (and any other sys.path directories)
FIRST.
So I did this. I then reinstalled setuptools from the setuptools-0.6c11-py2.7.egg
. It seemed successful but when I ran easy_install requests
I got basically the same error except the directory python2.6/dist-packages is now 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.
Also, when I do easy_install
and press tab I get these options
easy_install easy_install-2.6 easy_install-2.7
How come easy_install-2.6 is there?
and
How do I get easy-install working again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您是否尝试过像这样使用 sudo ?
或者将安装目录指定为您有写入权限的目录。
但您确实应该使用 PIP 而不是
easy_install
。它更好并且有更多的功能。Did you try using
sudo
like this?Or specify the install directory to a directory that you have write privileges.
But you should really use PIP instead of
easy_install
. It is much better and has a lot more features.您应该在基于包的 Linux 发行版上使用 virtualenv,这样 Python 脚本就不会干扰其他包或与操作系统的包管理器发生冲突。
http://workaround.org/easy-install-debian
You should use
virtualenv
on package-based Linux distributions so Python scripts don't interfere with other packages or conflict with the OS's package-manager.http://workaround.org/easy-install-debian
以下内容对我来说适用于 Ubuntu 12.10 安装 easy_install 然后 pip:
The following worked for me with Ubuntu 12.10 installing easy_install then pip:
您是否尝试过将新的 python.framework 添加到路径中?
在山狮上我添加了
/Library/Frameworks/Python.framework/Versions/3.3/bin/
到
/etc/paths
然后我就可以使用 easy_install-3.3 和 pip-3.3
Have you tried adding your new python.framework to path?
On mountain lion I added
/Library/Frameworks/Python.framework/Versions/3.3/bin/
to
/etc/paths
and then I was able to use easy_install-3.3 and pip-3.3
在
easy_install
之前使用Sudo
可能会解决您的问题,谢谢
Using
Sudo
beforeeasy_install
may solve your problemthanks
这可能是一个简单的情况,您在前面缺少“sudo”。您可以尝试使用 sudo easy-install 请求,
输入“sudo”将添加所需的权限。
It might be a simple case of you missing "sudo" in the front. Can you try it with sudo easy-install requests
putting the "sudo" will add the required permissions.