如何安装 python distutils

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3810521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 12:50:38  来源:igfitidea点击:

how to install python distutils

pythondistutils

提问by Neo

I just got some space on a VPS server(running on ubuntu 8.04), and I'm trying to install django on it. The server has python 2.5 installed, but I guess its non standard installation. When I run install script for django, I get

我刚刚在 VPS 服务器上获得了一些空间(在 ubuntu 8.04 上运行),我正在尝试在其上安装 django。服务器安装了 python 2.5,但我猜它是非标准安装。当我为 django 运行安装脚本时,我得到

amitoj@ninja:~/Django-1.2.1$ python setup.py install
Traceback (most recent call last):
  File "setup.py", line 1, in <module>
    from distutils.core import setup
ImportError: No module named distutils.core

I'm stumped. All the articles on internet tell me how to install modules using distutils. But how do I get distutils itself? Can anyone point me to the archive for distutils? I looked in /usr/lib/local/python2.5, /usr/lib/python2.5 etc, and as expected there is no distutils to be found.

我难住了。互联网上的所有文章都告诉我如何使用 distutils 安装模块。但是我如何获得 distutils 本身呢?任何人都可以指出我的 distutils 档案吗?我查看了 /usr/lib/local/python2.5、/usr/lib/python2.5 等,正如预期的那样,没有找到 distutils。

采纳答案by Duncan

The simplest way to install setuptools when it isn't already there and you can't use a package manager is to download ez_setup.pyand run it with the appropriate Python interpreter. This works even if you have multiple versions of Python around: just run ez_setup.py once with each Python.

当 setuptools 尚不存在且您无法使用包管理器时,安装它的最简单方法是下载ez_setup.py并使用适当的 Python 解释器运行它。即使您有多个 Python 版本,这也有效:只需对每个 Python 运行 ez_setup.py 一次。

Edit: note that recent versions of Python 3 include setuptools in the distribution so you no longer need to install separately. The script mentioned here is only relevant for old versions of Python.

编辑:请注意,最新版本的 Python 3 在发行版中包含 setuptools,因此您不再需要单独安装。这里提到的脚本只与旧版本的 Python 相关。

回答by Manoj Govindan

You can install the python-distutilspackage. sudo apt-get install python-distutilsshould suffice.

您可以安装该python-distutils软件包。sudo apt-get install python-distutils应该足够了。

回答by sheki

You can try installing Python 2.6,

您可以尝试安装 Python 2.6,

sudo apt-get install python2.6

sudo apt-get install python2.6

This should install the latest Python and also distutils package.

这应该安装最新的 Python 和 distutils 包。

回答by éric Araujo

If the system Python is borked (i.e. the OS packages split distutils in a python-devel package) and you can't ask a sysadmin to install the missing piece, then you'll have to install your own Python. It requires some header files and a compiler toolchain. If you can't have those, try compiling a Python on an identical computer and just copying it.

如果系统 Python 被 borked(即操作系统包在 python-devel 包中拆分 distutils)并且您不能要求系统管理员安装缺少的部分,那么您将必须安装自己的 Python。它需要一些头文件和一个编译器工具链。如果您不能拥有这些,请尝试在相同的计算机上编译 Python 并复制它。

回答by mightypile

I ran across this error on a Beaglebone Black using the standard Angstrom distribution. It is currently running Python 2.7.3, but does not include distutils. The solution for me was to install distutils. (It required su privileges.)

我在使用标准 Angstrom 发行版的 Beaglebone Black 上遇到了这个错误。它目前运行的是 Python 2.7.3,但不包括 distutils。我的解决方案是安装 distutils。(它需要 su 权限。)

    su
    opkg install python-distutils

After that installation, the previously erroring command ran fine.

安装后,之前出错的命令运行良好。

    python setup.py build

回答by ettanany

I know this is an old question, but I just come across the same issue using Python 3.6 in Ubuntu, and I am able to solve it using the following command:

我知道这是一个老问题,但我只是在 Ubuntu 中使用 Python 3.6 遇到了同样的问题,我可以使用以下命令解决它:

sudo apt-get install python3-distutils

回答by Mohammad Heydari

you can use sudo apt-get install python3-distutilsby root permission.

您可以sudo apt-get install python3-distutils通过root权限使用。

i believe it worked here

我相信它在这里有效

回答by Ben Amos

If you are unable to install with either of these:

如果您无法使用以下任一方式进行安装:

sudo apt-get install python-distutils
sudo apt-get install python3-distutils

Try this instead:

试试这个:

sudo apt-get install python-distutils-extra

Ref: https://groups.google.com/forum/#!topic/beagleboard/RDlTq8sMxro

参考:https: //groups.google.com/forum/#!topic/beagleboard/ RDlTq8sMxro