Python setup.py : Could not find suitable distribution for Requirement. 解析 ('tensorflow' )

标签 python tensorflow anaconda conda

我有 tensorflowinstall_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.0tensorflow-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/

相关文章:

dependencies - 有没有办法强制 conda install 安装软件包及其依赖项而不是给出错误

python - beautifulsoup .select 不返回任何内容

python - 如何高效地逐行处理python中的字符串?

python - 用带反斜杠的字符串替换字符串

python - 如何使用经过训练的神经网络(Tensorflow 2.0,回归分析)预测新数据?

python - 如何使用 TF1.3 中的新数据集 api 映射具有附加参数的函数?

tensorflow - 凯拉斯 GlobalMaxPooling2D 类型错误 : ('Keyword argument not understood:' , 'keepdims' )

Python lxml : insert text at given position relatively to subelements

python - 如何修复 conda 中的包解析警告?

python - 如何从 Datareader pandas 中挑选出单独的数值列?