使用 pip 安装 tensorflow 时出错,没有名为 'termcolor' 的模块

Error installing tensorflow with pip, no module named 'termcolor'

我正在尝试使用 pip install tensorflow 安装 tensorflow。我可以安装其他软件包,但 tensorflow 无法正常工作。这是我得到的错误:

C:\Users\sebas>python -m pip install tensorflow

Collecting tensorflow
Using cached tensorflow-2.8.0-cp37-cp37m-win_amd64.whl (437.9 MB)
Collecting h5py>=2.9.0
Using cached h5py-3.6.0-cp37-cp37m-win_amd64.whl (2.8 MB)
Collecting tensorboard<2.9,>=2.8
Using cached tensorboard-2.8.0-py3-none-any.whl (5.8 MB)
Collecting termcolor>=1.1.0
Using cached termcolor-1.1.0.tar.gz (3.9 kB)
Preparing metadata (setup.py) ... 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 36, in <module>
File "pip-setuptools-caller>", line 34, in <module>
File "C:\Users\sebas\AppData\Local\Temp\pip-install-vmfvacm3 \termcolor_be9b831904ce413daecad52b36f017aa\setup.py", line 35, in <module>
from termcolor import VERSION
ModuleNotFoundError: No module named 'termcolor'
[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. \

对于有类似问题的人(Windows)


主要问题是termcolor

它似乎试图从新版本(安装前)导入 VERSION,但它的行为就像加载没有 VERSION.

的旧版本一样

您可以从

下载 termcolor 作为文件 .whl

Unofficial Windows Binaries for Python Extension Packages

并尝试安装

pip install termcolor‑1.1.0‑py2.py3‑none‑any.whl