简体   繁体   English

更新 python 版本后使用 pipenv 的错误

[英]Errors to use pipenv after updating python version

recently I have updated my default python to be 3.10 but I realized that some parts of my OS started to broke;最近我将我的默认 python 更新为 3.10,但我意识到我的操作系统的某些部分开始损坏;

I can use python -m venv venv and it works like a charm, but if I try to activate a pipenv shell I do receive some errors It has started by raising errors in the collections.MutableMapping so I changed it to collections.abc.MutableMapping ... But it doesn't stop raising errors and I can't remove the pipenv. I can use python -m venv venv and it works like a charm, but if I try to activate a pipenv shell I do receive some errors It has started by raising errors in the collections.MutableMapping so I changed it to collections.abc.MutableMapping ...但它不会停止引发错误,我无法删除 pipenv。

When I try to pipenv shell or even pipenv --rm I do receive the same message error当我尝试 pipenv shell 甚至 pipenv --rm 我确实收到相同的消息错误

ImportError: cannot import name 'InvalidHeader' from 'requests.packages.urllib3.exceptions' (/usr/lib/python3/dist-packages/pipenv/vendor/requests/packages/urllib3/exceptions.py)

在此处输入图像描述

As I can't find references on how to fix this, any help you can provide will be really appreciated guys.由于我找不到有关如何解决此问题的参考资料,因此您可以提供的任何帮助将不胜感激。

Regards, Leonardo问候,莱昂纳多

Running with a new Ubuntu 22.04 system, I faced the same urllib3 collections issue you report as your initial problem:使用新的 Ubuntu 22.04 系统运行时,我遇到了与您报告的最初问题相同的 urllib3 collections问题:

$ pipenv install
Traceback (most recent call last):
  <snip>
  File "/usr/lib/python3/dist-packages/pipenv/vendor/requests/packages/urllib3/_collections.py", line 2, in <module>
    from collections import Mapping, MutableMapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

I found a discussion of this in the pipenv github's issue page here: https://github.com/pypa/pipenv/issues/5088我在 pipenv github 的问题页面中找到了对此的讨论: https://github.com/pypa/pipenv/issues/5088

Apparently there is a problem with Python 3.10 with the apt-installed version of pipenv.显然 Python 3.10 与 apt-installed 版本的 pipenv 存在问题。 I suppose the apt repositories should obtain an updated pipenv?我想 apt 存储库应该获得更新的 pipenv? In any case, taking the input from amod-amatya , I installed pipenv via pip (on my system, my packages are installed via sudo , but running as a non-sudo user should work as well):无论如何,从amod-amatya获取输入,我通过pip (在我的系统上,我的包是通过sudo安装的,但以非 sudo 用户身份运行也应该可以):

sudo pip install --upgrade pipenv

FWIW, I didn't uninstall the apt version of pipenv. FWIW,我没有卸载 apt 版本的 pipenv。 With that pip-installed pipenv version, pipenv now works for me:使用 pip 安装的 pipenv 版本,pipenv 现在对我有用:

$ pipenv --version
pipenv, version 2022.5.2

$ pipenv install 
<snip>
Building requirements...
Resolving dependencies...
_ Success! 
Updated Pipfile.lock (1d3b5e)!
Installing dependencies from Pipfile.lock (1d3b5e)...
  __   ________________________________ 3/3 _ 00:00:01
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM