`pip-install`在某些程序包上出现错误



当我尝试使用pip install安装某些软件包时,它们会出现错误。这是我尝试安装chatterbot时的错误,但其他一些软件包也会出现此错误:

pip install chatterbot
Collecting chatterbot
Using cached ChatterBot-1.0.5-py2.py3-none-any.whl (67 kB)
Collecting pint>=0.8.1
Downloading Pint-0.19.2.tar.gz (292 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 292.0/292.0 kB 1.6 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting pyyaml<5.2,>=5.1
Using cached PyYAML-5.1.2.tar.gz (265 kB)
Preparing metadata (setup.py) ... done
Collecting spacy<2.2,>=2.1
Using cached spacy-2.1.9.tar.gz (30.7 MB)
Installing build dependencies ... error
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [35 lines of output]
Collecting setuptools
Using cached setuptools-65.0.1-py3-none-any.whl (1.2 MB)
Collecting wheel<0.33.0,>0.32.0
Using cached wheel-0.32.3-py2.py3-none-any.whl (21 kB)
Collecting Cython
Using cached Cython-0.29.32-py2.py3-none-any.whl (986 kB)
Collecting cymem<2.1.0,>=2.0.2
Using cached cymem-2.0.6-cp310-cp310-win_amd64.whl (36 kB)
Collecting preshed<2.1.0,>=2.0.1
Using cached preshed-2.0.1.tar.gz (113 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
error: subprocess-exited-with-error
python setup.py egg_info did not run successfully.
exit code: 1
[6 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "C:UsersogulsAppDataLocalTemppip-install-qce7tdofpreshed_546a51fe26c74852ab50db073ad57f1fsetup.py", line 9, in <module>
from distutils import ccompiler, msvccompiler
ImportError: cannot import name 'msvccompiler' from 'distutils' (C:UsersogulsAppDataLocalProgramsPythonPython310libsite-packagessetuptools_distutils__init__.py)
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
Encountered error while generating package metadata.
See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.

我不知道是哪些软件包导致了这个错误,很多软件包安装时没有任何问题

我尝试过更新pip、更改环境变量和其他我在互联网上找到的可能的解决方案,但似乎都不起作用。

编辑:我尝试安装的软件包支持我的Python版本。

您的案例中真正的错误是:

ImportError: cannot import name 'msvccompiler' from 'distutils'

发生此错误是因为setuptools在版本65.0.0中损坏了distutils(并且在版本65.0.2中已经修复(。根据您的日志,此错误发生在您的全局setuptools安装中(请参阅错误消息中的路径(,因此您需要使用以下命令更新它:

pip install -U setuptools

然而,这些包可能仍然无法安装或无法正常工作,因为导致此错误的模块不支持当前支持的Python版本所需的编译器版本。

根据我的经验,这是Python3.10的一个问题。我犯了这些错误,然后尝试了升级和降级。适用于Python 3.11或3.8。(无法添加评论,因此…(

同样的事情也发生在我身上,基本上是pip的版本问题。尝试将pip升级到最新版本--22.3.1,并将python版本从最新版本----3.10.00降级到3.9.13…

pip版本的pip --version检查

pip install notebook --upgrade-将pip更新为最新版本的命令

这对我有效

最新更新