这个问题很简略,因为 apt 装置的 pipenv 版本太老了,用最新的 pipenv 版本就好了,怎么取得最新的 pipenv 版本?间接用 pip 装置!
解决办法:
- 办法一:应用自带的 pip 装置最新的 pipenv,比方 ubuntu20 是自带的 pip3.8 能够装置,用命令
pip3 install pipenv
就好了 - 办法二:应用本人编译装置的 python 带的 pipenv 就好了
ubutu20 自带的 python 解释器是 python3.8
╰─➤ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.5 LTS
Release: 20.04
Codename: focal
我想装置一个 pipenv 来虚构环 python3.10
python3.10 是通过源码自行编译装置的,参考:Ubuntu20.04 从源代码编译装置 python3.10
通过上面的代码装置 pipenv
sudo apt install pipenv
而后创立虚拟环境
pipenv install --python=/home/pon/opt/python/cpython/python3.10/bin/python3.10
然而遇到了谬误
╰─➤ pipenv install --python=/home/pon/opt/python/cpython/python3.10/bin/python3.10 130 ↵
Virtualenv already exists!
Removing existing virtualenv…
Creating a virtualenv for this project…
Using /home/pon/opt/python/cpython/python3.10/bin/python3.10 (3.10.7) to create virtualenv…
⠋created virtual environment CPython3.10.7.final.0-64 in 816ms
creator CPython3Posix(dest=/home/pon/.local/share/virtualenvs/tracksource-XXsh2Vxq, clear=False, global=False)
seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/pon/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
Virtualenv location: /home/pon/.local/share/virtualenvs/tracksource-XXsh2Vxq
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
from . import utils
File "/usr/lib/python3/dist-packages/pipenv/vendor/requests/utils.py", line 27, in <module>
from .cookies import RequestsCookieJar, cookiejar_from_dict
File "/usr/lib/python3/dist-packages/pipenv/vendor/requests/cookies.py", line 172, in <module>
class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'
解决办法还是什么呢?
应用 python3.10 装置 pipenv
~/opt/python/cpython/python3.10/bin/pip3.10 install pipenv
查看版本,能够看到时最新的
─➤ pipenv --version
pipenv, version 2022.10.10
用这个最新的 pipenv 就能够创立 python3.10 的虚拟环境了
pipenv install --python=/home/pon/opt/python/cpython/python3.10/bin/python3.10 130 ↵
Creating a virtualenv for this project...
Pipfile: /home/pon/code/vobile/tracksource/Pipfile
Using /home/pon/opt/python/cpython/python3.10/bin/python3.10 (3.10.7) to create virtualenv...
⠴ Creating virtual environment...created virtual environment CPython3.10.7.final.0-64 in 799ms
creator Venv(dest=/home/pon/.local/share/virtualenvs/tracksource-XXsh2Vxq, clear=False, no_vcs_ignore=False, global=False, describe=CPython3Posix)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/pon/.local/share/virtualenv)
added seed packages: pip==22.2.2, setuptools==65.3.0, wheel==0.37.1
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
✔ Successfully created virtual environment!
Virtualenv location: /home/pon/.local/share/virtualenvs/tracksource-XXsh2Vxq
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Locking [dev-packages] dependencies...
Updated Pipfile.lock (fedbd2ab7afd84cf16f128af0619749267b62277b4cb6989ef16d4bef6e4eef2)!
Installing dependencies from Pipfile.lock (e4eef2)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
ubuntu20 apt 仓库中的 pipenv 有多老?
╰─➤ pipenv --version >
pipenv, version 11.9.0
所以这个问题通知咱们,对于命令行工具,尽可能用 pip 装置,而不是 Linux 发行版仓库中的版本