什么是"错误:选项 - 单个版本 - 外部管理无法识别"表示什么?

kef*_*ich 97 python pip distribute

我似乎突然开始遇到变量包(包括和)error: option --single-version-externally-managed not recognized时的错误.我之前从未见过这个错误,但它现在也出现在travis-ci版本中,没有任何改变.pip installPyObjCastropy

此错误是否表示过期分发?或者一些错误指定的选项setup.py?或完全不同的东西?

wyn*_*emo 136

添加--egg选项

pip install --egg SCons
Run Code Online (Sandbox Code Playgroud)

我使用pip1.4.1版

  • 有人可以详细解释这个选项意味着什么,为什么这个有用? (13认同)
  • 这是唯一真正有用的解决方案.最近的pip和setuptools已经安装完毕,不过我还是承担了这个错误. (10认同)
  • `没有这样的选项:--egg` in pip 18.1 (6认同)
  • 虽然这对我有用,但我也得到了错误:"DEPRECATION: - egg已被弃用,将来会被删除.这个标志与pip的大部分互斥,实际使用它会使pip的管理能力无效安装过程." (4认同)

Kel*_*tek 74

新更新:

安装最新版本setuptools.如果仍然出现错误,请wheel同时安装.

pip install -U setuptools
pip install -U wheel
Run Code Online (Sandbox Code Playgroud)

原始答案/更多详情:

--single-version-externally-managed 是一个用于Python包的选项,指示setuptools模块创建一个Python包,如果需要,可以由主机的包管理器轻松管理,如Yum或Apt.

如果您看到此消息,则可能有旧版本的setuptools或Python.尝试使用Distribute,这是一个较新版本的setuptools,并且向后兼容.这些包可能会让您拥有它.

https://pypi.python.org/pypi/distribute

编辑:此时,分发已合并到主setuptools项目中.只需安装最新版本setuptools.正如@wynemo指出的那样,您可能希望使用该--egg选项,因为它更适合那些您不打算创建系统包以进行分发的手动安装.

  • 应该补充一点:不要再使用发布了.Distribute已经合并回setuptools项目,所以现在只有一个`setuptools`来统治它们. (17认同)
  • 到了 2020 年,这两种方法都不适合我。 `--egg` 选项消失了,我安装了最新的 `setuptools` 和 `wheel`,但仍然收到此错误:(。也许我需要重新创建我的 conda 环境。 (3认同)

Set*_*ley 44

安装wheel解决了这个问题与最近pip(我使用8.1.2):

pip install wheel
Run Code Online (Sandbox Code Playgroud)


spa*_*owt 7

尝试升级setuptools,如下所示:

pip install --upgrade setuptools


san*_*ans 5

我遇到了这个问题.事实证明,我的pip缓存上的文件权限存在问题.

如果你在pip输出的最开头看到一条消息,比如

The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Run Code Online (Sandbox Code Playgroud)

你可能有同样的问题.您可以通过确保对pip缓存具有适当的文件权限(例如chown -R $(whoami) /home/ubuntu/.cache/pip)来解决此问题,或者,如果您在UNIX上,则可以使用XDG_CACHE_HOMEenv var 将pip缓存位置设置为您拥有的某个文件夹.