ModuleNotFoundError: No module named ‘distutils.cmd‘

ubuntu 22.04 LTS

python3.10

版本太高,需要python3.6,python3.8版本

根据需求,切换,保证原有的系统正常使用;

以,python3.8为例:

1 Ubuntu安装Python3.8

一、安装Python3.8

Ubuntu 官方 apt 库中还未收录 python 3.8,这里使用 deadsnakes PPA 软件源安装。

1、安装依赖包

bash 复制代码
$ sudo apt-get update
$ sudo apt-get install software-properties-common

2、添加 deadsnakes PPA 源

bash 复制代码
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update

3、安装 python 3.8

bash 复制代码
$ sudo apt-get install python3.8

2 启动虚拟环境

bash 复制代码
 $ virtualenv -p  /usr/bin/python3.8 PY38 --python=python3.8
created virtual environment CPython3.8.17.final.0-64 in 335ms
  creator CPython3Posix(dest=/home/book/code/aaa/PY38, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/book/.local/share/virtualenv)
    added seed packages: pip==22.0.2, setuptools==59.6.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

3 启动Pip3报错

bash 复制代码
    from distutils.cmd import Command as DistutilsCommand

解决方法:

bash 复制代码
$ sudo apt-get install python3.8-distutils
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  python3.8-lib2to3
The following NEW packages will be installed:
  python3.8-distutils python3.8-lib2to3
0 upgraded, 2 newly installed, 0 to remove and 296 not upgraded.
Need to get 319 kB of archives.
After this operation, 1,237 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 python3.8-lib2to3 all 3.8.17-1+jammy1 [126 kB]
Get:2 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy/main amd64 python3.8-distutils all 3.8.17-1+jammy1 [193 kB]
Fetched 319 kB in 11s (28.9 kB/s)
Selecting previously unselected package python3.8-lib2to3.
(Reading database ... 212247 files and directories currently installed.)
Preparing to unpack .../python3.8-lib2to3_3.8.17-1+jammy1_all.deb ...
Unpacking python3.8-lib2to3 (3.8.17-1+jammy1) ...
Selecting previously unselected package python3.8-distutils.
Preparing to unpack .../python3.8-distutils_3.8.17-1+jammy1_all.deb ...
Unpacking python3.8-distutils (3.8.17-1+jammy1) ...
Setting up python3.8-lib2to3 (3.8.17-1+jammy1) ...
Setting up python3.8-distutils (3.8.17-1+jammy1) ...
$pip install -r src/requirements.txt
相关推荐
y先森35 分钟前
CSS3中的伸缩盒模型(弹性盒子、弹性布局)之伸缩容器、伸缩项目、主轴方向、主轴换行方式、复合属性flex-flow
前端·css·css3
前端Hardy35 分钟前
纯HTML&CSS实现3D旋转地球
前端·javascript·css·3d·html
susu108301891138 分钟前
vue3中父div设置display flex,2个子div重叠
前端·javascript·vue.js
IT女孩儿2 小时前
CSS查缺补漏(补充上一条)
前端·css
吃杠碰小鸡3 小时前
commitlint校验git提交信息
前端
虾球xz3 小时前
游戏引擎学习第20天
前端·学习·游戏引擎
我爱李星璇3 小时前
HTML常用表格与标签
前端·html
疯狂的沙粒3 小时前
如何在Vue项目中应用TypeScript?应该注意那些点?
前端·vue.js·typescript
小镇程序员4 小时前
vue2 src_Todolist全局总线事件版本
前端·javascript·vue.js
野槐4 小时前
前端图像处理(一)
前端