使用pipenv安装TensorFlow会出错

时间:2019-12-11 01:21:36

标签: python tensorflow pipenv

我正在尝试使用 pipenv 安装 TensorFlow

这是我的Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pylint = "*"

[packages]
python-telegram-bot = "*"
imdbpy = "*"
matplotlib = "*"
scikit-image = "*"
scikit-learn = "*"
tensorflow = "*"

[requires]
python_version = "3.8"

然后我运行:

pipenv install tensorflow

哪个输出:

Installing tensorflow…
Adding tensorflow to Pipfile's [packages]…
Installation Succeeded
Pipfile.lock (989c3d) out of date, updating to (0d6760)…
Locking [dev-packages] dependencies…
Success!
Locking [packages] dependencies…
Locking Failed!

其后是大回溯,结尾为:

pipenv.patched.notpip._internal.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in C:\Users\lucas\AppData\Local\Temp\tmpyh639mq4build\functools32\

我的虚拟环境使用 Python 3.8.0 64位

我在做什么错了?

1 个答案:

答案 0 :(得分:3)

正如评论所指出的那样,Tensorflow仅支持python 3.7(截至2020年3月)。您可以在文档的system requirements page中找到更多信息。

因此,要解决您的问题,

  1. 使用pipenv --rm删除虚拟环境
  2. 删除Pipfile.lock
  3. 将Pipfile的最后几行更改为
    [requires]
    python_version = "3.7"
    
  4. 运行pipenv install --dev再次重新创建环境,运行pipenv install tensorflow安装tensorflow

完成!