无法导入从源代码分发安装所需的setuptools。请安装setuptools

时间:2018-07-11 14:28:51

标签: python python-3.x setuptools

我正在尝试安装使用python编写的特定工具。为了安装它,我需要运行:

python3.6 setup build
python3.6 setup install

但是,当我运行它时,我会收到以下警告:

/usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
/usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution 
option: 'setup_requires'
warnings.warn(msg)
/usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution 
option: 'tests_require'
warnings.warn(msg)

所以我试图从我从pypi下载的本地文件中安装setuptools:

python3.6 -m pip install setuptools-39.2.0.zip 
Processing ./setuptools-39.2.0.zip
Could not import setuptools which is required to install from a source     distribution.
Please install setuptools.

我尝试按照您的建议安装whl文件:

 pip3.6 install setuptools-40.0.0-py2.py3-none-any.whl 
Requirement already satisfied: setuptools==40.0.0 from     file:///PostgreSQL/installs/setuptools-40.0.0-py2.py3-none-any.whl in /usr/local/lib/python3.6/site-packages

但是,在尝试安装python工具时仍然遇到相同的错误。我该怎么办?

注意:我现在意识到,当我尝试用其他用户(不是root用户)构建工具时,我没有得到这些错误,但是python3.6 setup.py安装部分失败了,因为用户没有特权。那么,为什么根失败了?

谢谢

3 个答案:

答案 0 :(得分:0)

如果您使用任何基于Linux的Debian,请使用:

sudo apt-get install python3-pip

这将安装所有必需的软件包。

答案 1 :(得分:0)

如果您可以访问互联网,则可以使用操作系统包管理器安装python3-setuptools:

OpenSuSE / SLES: zypper in python3-setuptools

CentOS: yum install python3-setuptools

Debian / Ubuntu: apt-get install python3-setuptools

答案 2 :(得分:0)

我的PATH变量有问题。将其更改为其他用户的PATH可以为我解决。