我在安装Python 3中的包时遇到了麻烦。

我总是用setup.py install安装包。但是现在,当我尝试安装anicolors包时,我得到:

importerror "No Module named Setuptools"

我不知道该怎么做,因为我过去没有安装安装工具。尽管如此,我仍然能够使用setup.py install安装许多包,而不需要setuptools。为什么我现在要安装工具?

我甚至不能安装setuptools,因为我有Python 3.3和setuptools不支持Python 3。

为什么我的安装命令不再工作了?


当前回答

如果pip没有安装,比如它来自死蛇PPA,或者Docker环境,修复此错误的最佳方法是通过运行引导它

python -m ensurepip

其他回答

确保您正在运行最新版本的pip

我试着安装Ansible,但是失败了

ModuleNotFoundError:没有名为“setuptools_rust”的模块

Python3-setuptools已经到位,所以升级PIP解决了这个问题。

pip3 install -U pip

我是在Oracle Linux 6.4上使用Python 2.6的virtualenv中做这件事的,所以基于apt的解决方案对我来说不是一个选择,Python 2.7的想法也不是。我的解决方案是升级我的setuptools版本,它已经被virtualenv安装:

pip install --upgrade setuptools

在那之后,我能够将包安装到virtualenv中。

我在安装pyunicorn时遇到了这样的问题。我想在谷歌Colab上安装它。我试着直接从Github安装pyunicorn,它为我工作。以我为例,它是这样的:

pip install git+https://github.com/pik-copan/pyunicorn.git#egg=pyunicorn

分发包提供了与Python 3兼容的setuptools版本:http://pypi.python.org/pypi/distribute

另外,使用pip安装模块。它会自动找到依赖项并为您安装它们。

你的包对我来说很好:

[~] pip --version                                                              
pip 1.2.1 from /usr/lib/python3.3/site-packages (python 3.3)
[~] sudo pip install ansicolors                                                
Downloading/unpacking ansicolors
  Downloading ansicolors-1.0.2.tar.gz
  Running setup.py egg_info for package ansicolors

Installing collected packages: ansicolors
  Running setup.py install for ansicolors

Successfully installed ansicolors
Cleaning up...
[~]

我的解决方案是升级我的setuptools:

python3 -m pip install --upgrade pip setuptools wheel