【问题标题】:Error installing tensorflow with pip, no module named 'termcolor'使用 pip 安装 tensorflow 时出错,没有名为“termcolor”的模块
【发布时间】:2022-07-14 03:42:26
【问题描述】:

我正在尝试使用 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>
@ 987654339@
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.\

【问题讨论】:

  • 您是否尝试先安装 termcolor ?也许它会显示更多信息。
  • 是的,当我尝试安装 tensorflow 时,它给了我同样的错误。
  • 所以主要问题是termcolor,您需要找出它无法安装的原因。 pip 具有选项--verbose,当您安装termcolor 时可能会显示更多信息。也许它需要一些你必须单独安装的 C/C++ 库(而不是 pip)。
  • 我检查了包termcolor 中的文件setup.py,看起来它在安装之前尝试加载termcolor 以获取VERSION。旧版本 0.2 不这样做。也许首先安装旧版本pip install termcolor==0.2,然后更新到新版本pip install -U termcolor
  • 你也可以从Unofficial Windows Binaries for Python Extension Packages下载termcolor作为文件.whl并尝试安装pip install termcolor‑1.1.0‑py2.py3‑none‑any.whl

标签: python tensorflow termcolor


【解决方案1】:

对于会遇到类似问题的人(在 Windows 上)


主要问题是termcolor

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

您可以从

下载termcolor作为文件.whl

Unofficial Windows Binaries for Python Extension Packages

并尝试安装

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

【讨论】:

    【解决方案2】:

    如果在 Unofficial Windows Binaries for Python Extension Packages 上找不到 termcolor‑1.1.0‑py2.py3‑none‑any.whl,您可以在这里找到它 termcolor-whl · PyPI

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-07-30
      • 2018-05-24
      • 2014-12-23
      • 2019-11-07
      • 2015-10-24
      • 2016-10-26
      • 2019-02-20
      • 2016-06-16
      相关资源
      最近更新 更多