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

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

importerror "No Module named Setuptools"

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

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

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


当前回答

第一步#1 你必须安装setuptools

在Linux上: pip install -U pip setuptools

在Mac OS上: pip install -U pip setuptools

在Windows上: python -m pip install -U pip setuptools

第二步:

确保您已使其可访问(使其在环境变量中可用)

在Linux上 导出路径= " INSTALLATIONDIRECTORY: $路径”

在Mac OS上 对不起,我不知道。

在Windows上 打开开始搜索,输入“env”,然后选择“编辑系统环境变量” 点击“环境变量”按钮。 根据需要设置环境变量。New按钮添加了一个额外的变量。 选择“OK”,关闭所有对话框。您的更改被保存!

其他回答

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

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

当我的pip requirements.txt文件包含一个使用诗词构建的可编辑库并包含一个pyproject时,我就遇到了这个问题。toml文件。遵循setuptools的文档,我的解决方案是将setuptools添加到pyproject中的构建系统需求中。Toml文件如下:

[build-system]
requires = ["poetry-core>=1.0.0", "setuptools"]
build-backend = "poetry.core.masonry.api"

在macOS上,如果你安装了自制程序,只需运行:

brew install rust

PyPA推荐的用于安装和管理Python包的工具是pip。pip包含在Python 3.4 (PEP 453)中,但对于旧版本,这里是如何安装它(在Windows上):

下载https://bootstrap.pypa.io/get-pip.py

>c:\Python33\python.exe get-pip.py
Downloading/unpacking pip
Downloading/unpacking setuptools
Installing collected packages: pip, setuptools
Successfully installed pip setuptools
Cleaning up...

>c:\Python33\Scripts\pip.exe install pymysql
Downloading/unpacking pymysql
Installing collected packages: pymysql
Successfully installed pymysql
Cleaning up...

对于其他由于不同原因而有相同问题的人:当有pyproject时也会发生这种情况。Toml和setup.py放在同一个目录下,即使setuptools可用。

删除pyproject。汤姆帮我解决了这个问题。