Ubuntu 18.04下Python3.10安装django-allauth失败求助
问题
在Ubuntu 18.04.6 LTS系统上使用Python3.10,尝试通过pip安装django-allauth时出现报错:
Collecting django-allauth Using cached django-allauth-0.51.0.tar.gz (709 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [20 lines of output] Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 14, in <module> File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 12, in <module> import setuptools.version File "/usr/lib/python3/dist-packages/setuptools/version.py", line 1, in <module> import pkg_resources File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 77, in <module> __import__('pkg_resources.extern.packaging.requirements') File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module> from pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException File "<frozen importlib._bootstrap>", line 1027, in _find_and_load File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 672, in _load_unlocked File "<frozen importlib._bootstrap>", line 632, in _load_backward_compatible File "/usr/lib/python3/dist-packages/pkg_resources/extern/__init__.py", line 43, in load_module __import__(extant) File "/usr/lib/python3/dist-packages/pkg_resources/_vendor/pyparsing.py", line 943, in <module> collections.MutableMapping.register(ParseResults) AttributeError: module 'collections' has no attribute 'MutableMapping' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output.
已尝试更新pip、安装setuptools、build-essential、g++,但问题仍未解决,寻求解决方法。
解决方法
- 卸载系统自带的旧版setuptools:
sudo apt remove python3-setuptools - 用Python3.10的pip安装最新版setuptools和wheel:
python3.10 -m pip install --upgrade setuptools wheel - 重新安装django-allauth:
python3.10 -m pip install django-allauth
若上述方法无效,可使用虚拟环境隔离依赖:
- 创建并激活虚拟环境:
python3.10 -m venv myenv source myenv/bin/activate - 在虚拟环境内安装最新依赖及django-allauth:
pip install --upgrade setuptools wheel pip install django-allauth
内容的提问来源于stack exchange,提问作者KarmaLover
相关产品推荐
相关产品推荐

