gpt4 book ai didi

python - 安装 python settuptools 时出错 - 没有这样的文件或目录 : '/usr/local/lib/python2.7/site-packages/test-easy-install-8811.pth'

转载 作者:太空宇宙 更新时间:2023-11-03 11:07:38 25 4
gpt4 key购买 nike

我正在尝试在没有 root 访问权限的 linux 机器上安装 settuptools。我已经创建了虚拟 python。

dgomez:~/download> which python
/home/dgomez/bin/python

当我执行以下操作时,出现错误:

/home/dgomez/bin/python ez_setup.py 

Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg
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 2] No such file or directory: '/usr/local/lib/python2.7/site-packages/test-easy-install-8816.pth'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/usr/local/lib/python2.7/site-packages/

This directory does not currently exist. Please create it and try again, or
choose a different installation directory (using the -d or --install-dir

选项)。

我想知道如何解决这个问题。我在其他论坛上看到用户通过创建目录来修复它,但在我的情况下,我没有 root 访问权限,因为我无法创建目录。谢谢

更新

我运行了 python

ez_setup.py --install-dir=/home/dgomez/lib/python2.7/site-packages/

Bu 仍然出现错误:

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

/home/dgomez/lib/python2.7/site-packages/

and your PYTHONPATH environment variable currently contains:

''

最佳答案

错误消息会告诉您确切的操作,使用 --install-dir--prefix 选项,以便将包安装到您的虚拟 Python 安装而不是默认位置。

这可能看起来像这样:

/home/dgomez/bin/python ez_setup.py --prefix=/home/dgomez

或者使用--install-dir:

/home/dgomez/bin/python ez_setup.py --install-dir=/home/dgomez/lib/python2.7/site-packages

请注意,您可能需要根据 Python 安装的 site-packages 目录的实际位置修改上述选项中使用的目录。

编辑:要修复您看到的新错误,您需要将该目录添加到 PYTHONPATH 环境变量中,您可以使用以下命令执行此操作:

export PYTHONPATH=$PYTHONPATH:/home/dgomez/lib/python2.7/site-packages/

如果您在 Mac 或 GNU/Linux 发行版上使用 bash,您可以将该行添加到您的 ~/.bashrc 文件中,这样您就不需要手动运行它。

关于python - 安装 python settuptools 时出错 - 没有这样的文件或目录 : '/usr/local/lib/python2.7/site-packages/test-easy-install-8811.pth' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14967032/

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