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
相关推荐
程序员爱技术1 小时前
Vue 2 + JavaScript + vue-count-to 集成案例
前端·javascript·vue.js
并不会2 小时前
常见 CSS 选择器用法
前端·css·学习·html·前端开发·css选择器
衣乌安、2 小时前
【CSS】居中样式
前端·css·css3
兔老大的胡萝卜2 小时前
ppk谈JavaScript,悟透JavaScript,精通CSS高级Web,JavaScript DOM编程艺术,高性能JavaScript pdf
前端·javascript
低代码布道师2 小时前
CSS的三个重点
前端·css
耶啵奶膘4 小时前
uniapp-是否删除
linux·前端·uni-app
王哈哈^_^5 小时前
【数据集】【YOLO】【目标检测】交通事故识别数据集 8939 张,YOLO道路事故目标检测实战训练教程!
前端·人工智能·深度学习·yolo·目标检测·计算机视觉·pyqt
cs_dn_Jie6 小时前
钉钉 H5 微应用 手机端调试
前端·javascript·vue.js·vue·钉钉
开心工作室_kaic6 小时前
ssm068海鲜自助餐厅系统+vue(论文+源码)_kaic
前端·javascript·vue.js
有梦想的刺儿7 小时前
webWorker基本用法
前端·javascript·vue.js