我有 tensorflow
在 install_requires
中列为要求setup.py
的部分我的项目。
当我尝试将我的项目安装到新的 Anaconda 环境中时,出现以下错误:
$ python setup.py install
...
Searching for tensorflow
Reading https://pypi.org/simple/tensorflow/
No local packages or working download links found for tensorflow
error: Could not find suitable distribution for Requirement.parse('tensorflow')
我可以通过 conda “手动”安装 tensorflow 来解决这个问题:
$ conda install tensorflow
一旦我这样做了,安装通过
setup.py
工作顺利。我是否错误地认为我的环境有问题?如果不是,那么发生了什么,我该如何避免这个问题? (我担心我的包的用户将无法使用
setup.py
从源安装)我认为相关或可能提供线索的另一个奇怪之处是,我的 Anaconda 环境中列出的 TensorFlow 版本是 2.0,但如果我在运行 Python 时导入它,它似乎使用的是 1.15 版。例如:
$ conda list tensorflow
# packages in environment at /home/james/miniconda3/envs/cvdata_test:
#
# Name Version Build Channel
tensorflow 2.0.0 mkl_py37h66b46cc_0
tensorflow-base 2.0.0 mkl_py37h9204916_0
tensorflow-estimator 2.0.0 pyh2649769_0
$ python
Python 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 22:33:48)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'1.15.0-rc2'
这是在没有 GPU 的情况下运行 Ubuntu 18.04 的戴尔笔记本电脑上,因此解释器中显示的版本可能类似于
tensorflow-cpu
?如果我运行 pip freeze
我看到tensorflow==2.0.0
和 tensorflow-cpu==1.15.0rc2
,这有点令人困惑......
最佳答案
这似乎是由使用 Python 3.8 版引起的,该版本目前是不受支持的 Python 版本。一旦我使用 Python 3.7 版创建了一个新的 Anaconda 环境,这个问题就消失了。
唯一剩下的问题是我在运行 pip install -e .
时看到的这个错误对于我的项目,其中包括 tensorflow:
ERROR: tensorflow-cpu 1.15.0rc2 has requirement tensorboard<1.16.0,>=1.15.0, but you'll have tensorboard 2.1.0 which is incompatible.
ERROR: tensorflow-cpu 1.15.0rc2 has requirement tensorflow-estimator==1.15.1, but you'll have tensorflow-estimator 2.1.0 which is incompatible.
所以问题
tensorflow-cpu
当版本 2.1.0 显示为已安装版本时,实际安装了版本 1.15.0rc2 仍然是个谜。以机智:$ conda list tensorflow
# packages in environment at /home/james/miniconda3/envs/cvd:
#
# Name Version Build Channel
tensorflow 2.1.0 pypi_0 pypi
tensorflow-estimator 2.1.0 pypi_0 pypi
$ python -c "import tensorflow as tf; print(tf.__version__)"
1.15.0-rc2
关于Python setup.py : Could not find suitable distribution for Requirement. 解析 ('tensorflow' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59938365/