[英]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.