gpt4 book ai didi

python - 无法使用 easy_install 安装 Python 模块

转载 作者:太空狗 更新时间:2023-10-29 17:13:03 26 4
gpt4 key购买 nike

我正在尝试使用 easy_install 安装一个名为 requests 的模块

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并了解到我必须

delete all setuptools*.egg and setuptools.pth files from your system's site-packages directory (and any other sys.path directories) FIRST.

所以我这样做了。然后我从 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 是怎么来的?

我如何让简易安装再次工作?

最佳答案

你试过像这样使用 sudo 吗?

sudo easy_install requests

或者将安装目录指定为您具有写入权限的目录。

easy_install --install-dir=/home/foo/bar

但你真的应该使用PIP而不是 easy_install。它要好得多,并且具有更多功能。

关于python - 无法使用 easy_install 安装 Python 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7622562/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com