在python3上安装socketio模块似乎损坏了pip

问题描述

使用pip3 install socketio为python安装socketio软件包时,我得到了以下结果:

ERROR: launchpadlib 1.10.13 requires testresources,which is not installed.

WARNING: The scripts easy_install and easy_install-3.8 are installed in '/home/bill/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or,if you prefer to suppress this warning,use --no-warn-script-location.

Successfully installed netifaces-0.10.6 setuptools-3.3 socketio-0.2.1

尽管我能够成功import socketio,但pip3似乎已损坏(?)。 具体来说,当尝试在终端中运行包括pip3甚至是pip3在内的任何内容时,都会出现相同的错误:

Traceback (most recent call last):
  File "/usr/bin/pip3",line 6,in <module>
    from pkg_resources import load_entry_point
  File "/home/<username>/.local/lib/python3.8/site-packages/pkg_resources.py",line 1479,in <module>
    register_loader_type(importlib_bootstrap.SourceFileLoader,DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py",line 144,in apport_excepthook
    with os.fdopen(os.open(pr_filename,FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_bin_pip3.1000.crash'

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/pip3",DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

我尝试重新安装pip3,但没有帮助。我从ubuntu迁移到了mint,认为它的分布有些问题,但结果却相同。当我尝试删除python并重新安装它时,我也损坏了ubuntu,因为我无法使用pip,但是,您知道他们说的是什么,生活和学习。 编辑:using pip3: module "importlib._bootstrap" has no attribute "SourceFileLoader"上的任何内容都不适合我。

我当前正在使用linux mint 20,但是在ubuntu 20.04和20.04.1上遇到了相同的问题。

任何想法将不胜感激!

解决方法

编辑:Martijn Peters 指出这是您正在寻找的 socketio:https://pypi.org/project/python-socketio 如果您需要针对您发布的原始解决方案的解决方案,请继续阅读。

总结:pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched

我能够完全按照您的描述在运行 ubuntu:20.04 的 docker 容器中重现这一点,这给了我一些希望,我可以提供帮助。

我发现 socketiosetuptools==3.3 有依赖性,这对我来说似乎很奇怪,但这与为什么 pip 的核心功能在安装 后被破坏的原因一致socketio.

我不确定这个包在哪里维护,因为没有引用 git repo。我确实在 PKG-INFO 中找到了一个俄罗斯网站,但我不确定从那里去哪里......

这是一个 socketio 版本,它要求 setuptools>=42 以便没有任何问题:https://github.com/allenmcgehee/socketio-0.2.1-patched

最后,这是一个可以在不破坏 pip 的情况下为您安装 socketio 的命令: pip3 install git+https://github.com/allenmcgehee/socketio-0.2.1-patched

**我假设您已经修复了 pip。

,

也许你的意思是这个socketio?:https://pypi.org/project/python-socketio

python3 -m pip install python-socketio

字面上命名为“socketio”的包似乎只是过时且不受支持1,而“python-socketio”似乎还活着并已开发2 3

为此,在通过 pip 安装软件包时,查看类似的软件包并注意 typosquatting et al. 通常很有价值!

,

这发生在我身上,有一个不同的模块。我的解决方案是降级pip的版本和模块的版本。所以,对你来说,答案是运行:

python -m pip install pip== (previous version of your pip)
python -m pip uninstall socketio
python -m pip install socketio==0.2.0

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...