老式电脑安装python_如何为旧的python版本安装python-distutils

1586010002-jmsa.png

I am running Ubuntu 20.04 with python 3.6, 3.7, and 3.8 installed.

I am trying to install some packages using pip on 3.6 and 3.7 versions using 'python3.7 -m pip install package' but, I am getting this error:

ModuleNotFoundError: No module named 'distutils.util

I already have python3-distutils and python3-distutils-extra installed but pip only works for python 3.8.

How can I make pip work for installing packages on python 3.6 and 3.7?

解决方案

(from bounty description)

I want a definitive solution that does NOT involve someone telling me to install:

python-distutils

python3-distutils

python3-distutils-extra

I will be handing out FREE DOWNVOTES to anyone who mentions installing these.

Well, I have some bad news for you. There is no "official" way to get distutils on the Debian-provided python* packages without installing these packages, not unless you go outside of Debian's default package repositories.

This is a consequence of Debian's decision to break up various parts of Python's standard library into separate packages, on the basis of their policy to split things into runtime packages and development packages. They consider distutils to fall in the "development" part, and thus, don't distribute it as part of the standard python package.

Basically, your options are:

install a python*-distutils package.

This is what your OS maintainers recommend doing in your situation.

You've not explained why you'll "be handing out free downvotes" for anyone recommending this, but this is genuinely the "most correct" solution.

install Python, from somewhere that does not break up the standard library.

This would mean using a package source other than the official debian repositories.

The easiest source would be the deadsnakes ppa.

compile your own Python!

This isn't actually that difficult, and tools like pyenv make it easy to compile and manage multiple python versions.

hack around the problem!

You could... download the sources from CPython's repo, and place the Lib/distutils folder somewhere on the import path for pythonX.Y? This is a 100% hack though and I strongly recommend not doing this. If something bad happens, because you did this, I'm not responsible.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值