如何为旧的python版本安装python-distutils [英] How to install python-distutils for old python versions

查看:974
本文介绍了如何为旧的python版本安装python-distutils的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行安装了python 3.6、3.7和3.8的Ubuntu 20.04.

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

我正在尝试使用'python3.7 -m pip install package'在3.6和3.7版本上使用pip安装一些软件包,但是,我收到此错误:

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

我已经安装了python3-distutilspython3-distutils-extra,但是 pip仅适用于python 3.8 .

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

推荐答案

(来自赏金描述)

我想要一个不涉及任何人告诉我进行安装的最终解决方案:

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

  • python-distutils
  • python3-distutils
  • python3-distutils-extra
  • python-distutils
  • python3-distutils
  • python3-distutils-extra

我将向任何提到安装这些工具的人发放免费下载.

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

好吧,我有一些坏消息要告诉你.没有安装Debian提供的python*软件包就没有官方"方式,除非安装了Debian的默认软件包存储库.

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.

这是Debian决定将Python标准库的各个部分分解为单独的包的结果,这是基于他们将内容拆分为运行时包和开发包的策略.他们认为distutils属于开发"部分,因此,请勿将其作为标准python软件包的一部分进行分发.

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.

基本上,您的选择是:

  • 安装python*-distutils软件包.
    • 这是您的操作系统维护人员根据您的情况建议采取的措施.
    • 您还没有解释为什么为什么要向任何建议这样做的人分发免费的downvotes",但这确实是最正确的"解决方案.
    • 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.
      • 这意味着要使用官方debian仓库以外的软件包源.
      • 最简单的来源是 deadsnakes ppa .
      • 这实际上并不那么困难,并且 pyenv 之类的工具使编译和管理变得容易多个python版本.
      • This isn't actually that difficult, and tools like pyenv make it easy to compile and manage multiple python versions.
      • 您可以...从CPython的repo下载源,然后将Lib/distutils文件夹放在pythonX.Y导入路径上的某个位置?不过,这是100%的骇客,我强烈建议您不要这样做.如果发生了某些不好的事情(因为您这样做了),我不承担任何责任.
      • 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.

      这篇关于如何为旧的python版本安装python-distutils的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆