开发者问题收集

Pip 安装中存在 egg 碎片问题,导致软件包安装未知

2018-10-31
29348

我拿到了一台 MacBook Pro,需要确保我们的一些 Python 2.7 脚本可以在这台笔记本电脑上运行,就像在 Windows 机器上一样流畅。

这台 MacBook 很旧了,2008 年,OS X 10.11.6

我在使用 pip install 在这台笔记本电脑上安装某些软件包时遇到了麻烦,我在这里寻求帮助作为最后的手段。 首先,Python 2.7.10 已安装并运行顺利。 Pip install 也可以工作,但不是对所有软件包都有效。 首先,我安装了 python-vlc 包:

pip install python-vlc --user

安装完成,没有错误。然后我运行使用 import vlc 导入包的脚本

python script.py

导致

Traceback (most recent call last): File "script.py", line 30, in import vlc File "/Users/admin/Library/Python/2.7/lib/python/site-packages/vlc/ init .py", line 4, in from vlc.helper import tell File "/Users/admin/Library/Python/2.7/lib/python/site-packages/vlc/helper.py", line 4, in import applescript File "/Users/admin/Library/Python/2.7/lib/python/site-packages/applescript/ init .py", line 3, in import only ImportError: No module named only

似乎我只需要安装包:

pip install only --user

导致

Collecting only Installing collected packages: only Exception: Traceback (most recent call last): File "/Library/Python/2.7/site-packages/pip/_internal/cli/base_command.py", line 143, in main status = self.run(options, args) File "/Library/Python/2.7/site-packages/pip/_internal/commands/install.py", line 366, in run use_user_site=options.use_user_site, File "/Library/Python/2.7/site-packages/pip/_internal/req/ init .py", line 49, in install_given_reqs **kwargs File "/Library/Python/2.7/site-packages/pip/_internal/req/req_install.py", line 760, in install use_user_site=use_user_site, pycompile=pycompile, File "/Library/Python/2.7/site-packages/pip/_internal/req/req_install.py", line 382, in move_wheel_files warn_script_location=warn_script_location, File "/Library/Python/2.7/site-packages/pip/_internal/wheel.py", line 326, in move_wheel_files assert info_dir, "%s .dist-info directory not found" % req AssertionError: only .dist-info directory not found

因此,尝试手动下载它

pip download only

导致

Collecting only Running setup.py (path:/private/var/folders/jp/6s5zvb6s0kb19qdgy33sbkf40000gq/T/pip-download-C2CG6U/only/setup.py) egg_info for package only produced metadata for project name unknown. Fix your #egg=only fragments. Successfully downloaded unknown

我不太确定如何解决这个问题。如果我尝试继续安装,不管怎样

pip install only-1.0.2.tar.gz --user

Processing ./only-1.0.2.tar.gz Building wheels for collected packages: UNKNOWN Running setup.py bdist_wheel for UNKNOWN ... done Stored in directory: /Users/admin/Library/Caches/pip/wheels/13/bb/2c/bbbba0f8e56cc66e91a845dc17f9ba7045e5871aa88062798f Successfully built UNKNOWN Installing collected packages: UNKNOWN Found existing installation: UNKNOWN 0.0.0 Uninstalling UNKNOWN-0.0.0: Successfully uninstalled UNKNOWN-0.0.0 Successfully installed UNKNOWN-0.0.0

导致这个“未知”安装,因为它显示在 pip 列表中。现在,谷歌搜索显示有些人遇到了同样的问题,他们可以通过更新 setuptools 来解决这个问题。这台笔记本电脑上的 setuptools 版本是 1.1.6,所以我尝试更新它

pip install setuptools --upgrade --user

Collecting setuptools Using cached https://files.pythonhosted.org/packages/82/a1/ba6fb41367b375f5cb653d1317d8ca263c636cff6566e2da1b0da716069d/setuptools-40.5.0-py2.py3-none-any.whl applescript 0.0.1 requires only, which is not installed. applescript 0.0.1 requires temp, which is not installed. Installing collected packages: setuptools Successfully installed setuptools-40.5.0

它说它成功安装了 setuptools 40.5,但没有成功,因为 pip 列表保持不变。我又回到了原点,因为我只需要安装包(和临时包),但这会导致“未知”安装。 Applescript 是 0.0.1 版本。我无法升级它,因为它尝试仅安装包,但失败了。

我猜我需要在仅安装(和临时)包时解决 egg-info 问题,但我不知道如何解决。有人知道如何解决这个安装问题吗?

3个回答

我运行了这个

pip install setuptools --upgrade

...然后在我安装了 #egg\UNKNOWN 包后再次安装。

SinisterPenguin
2019-09-27

我找到了解决方法。如果有人遇到类似的问题,我希望这会有所帮助:

我根据setuptools规范手动编写了一个setup.py文件。

from setuptools import setup, find_packages

setup(name='only',
      version='1.0.2',
      packages=find_packages(),
     )

然后进入下载包的解压文件夹(在本例中,仅在pip下载后,进入only-1.0.2目录)。执行

python setup.py install

然后你就可以开始了。

Marc Vollenweid
2018-10-31

我遇到了同样的错误,尝试了这个

pip3 install --upgrade pip 

然后

pip3 install pandas

并且成功了

Marija D
2023-10-23