pipenv 在 Ubuntu 20.04 上失败

pipenv 在 Ubuntu 20.04 上失败

我尝试pipenv在 Ubuntu 20.04 上使用,但收到一条令人困惑的错误消息。首先,您必须安装pipenvpipenv在本地安装,而不是在系统范围内安装,否则您将陷入完全不同的麻烦!

  > pip3 install --user pipenv

并确保将其添加~/.local/bin到 PATH 环境变量的开头。当您尝试使用 时pipenv,您会收到错误:

      > pipenv --python 3.8
      Creating a virtualenv for this project…
      Pipfile: /home/alan/expr/pydemo-10.05.a/Pipfile
      Using /usr/bin/python3.8 (3.8.2) to create virtualenv…
      ⠙ Creating virtual environment...ModuleNotFoundError: No module named 'virtualenv.seed.via_app_data'

      ✘ Failed creating virtual environment 

      [pipenv.exceptions.VirtualenvCreationException]: 
      Failed to create virtual environment.

这里有什么问题?

答案1

我很幸运地偶然发现了答案在此主题中关于底层实现virtualenv

  > sudo pip3 uninstall virtualenv            # the latest version is broken
  > sudo pip3   install virtualenv==20.0.23   # this version works

此时就可以pipenv正常使用:

  > pipenv --python 3.8
  Creating a virtualenv for this project…
  Pipfile: /home/alan/expr/pydemo-10.05.a/Pipfile
  Using /usr/bin/python3.8 (3.8.2) to create virtualenv…
  ⠸ Creating virtual environment...created virtual environment CPython3.8.2.final.0-64 in 235ms
    creator CPython3Posix(dest=/home/alan/.local/share/virtualenvs/pydemo-10.05.a-MQUKFB85, clear=False, global=False)
    seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/home/alan/.local/share/virtualenv/seed-app-data/v1.0.1)
    activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator

  ✔ Successfully created virtual environment! 
  Virtualenv location: /home/alan/.local/share/virtualenvs/pydemo-10.05.a-MQUKFB85
  Creating a Pipfile for this project…

相关内容