当前位置:   article > 正文

ModuleNotFoundError: No module named ‘distutils.cmd‘_no module named 'distutils.cmd

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、安装依赖包

$ sudo apt-get update
$ sudo apt-get install software-properties-common
  • 1
  • 2

2、添加 deadsnakes PPA 源

$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
  • 1
  • 2

3、安装 python 3.8

$ sudo apt-get install python3.8
  • 1

2 启动虚拟环境

 $ 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

3 启动Pip3报错

    from distutils.cmd import Command as DistutilsCommand
  • 1

解决方法:

$ 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
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/562904
推荐阅读
相关标签
  

闽ICP备14008679号