python - 如何在没有 sudo 的情况下安装下载的 Python 包?

标签 python

我需要安装https://pypi.python.org/pypi/PasteScript在没有 sudo 访问权限的虚拟机上( this one ,如果相关)。我已经下载了它,但是当我运行 python setup.py install 时,我得到:

running install Checking .pth file support in /usr/local/lib/python2.7/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.7/dist-packages/test-easy-install-1621.pth'

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

/usr/local/lib/python2.7/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.

我发现的一个替代建议是使用 pip,但如果没有 sudo,我无法安装 pip。

PS:类似的问题有很多,但没有(我能找到!

最佳答案

关于:

python setup.py install --user

正如文档中所述,它应该按您的预期工作:https://docs.python.org/2/install/#alternate-installation-the-user-scheme

关于python - 如何在没有 sudo 的情况下安装下载的 Python 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49224272/

相关文章:

python - 从命令行将列表传递给 Python

python - 为什么 pd.concat 将结果数据类型从 int 更改为 float?

python - 如何调试被覆盖的 sys.modules 条目?

python - 超像素分割问题(​​python 中的 opencv) - 分割掩码轮廓中的孔洞

Python Unicode、Pyramid、UTF-8 MySQL 表问题

python - 在 Python OrderedDict 中获取关键索引?

python - 这个 `if` 条件是否曾经运行过?

python - 避免内存泄漏

python - 了解 concurrent.futures.Executor.map()

python - 如何在 python 中处理多个模块/包?