Python setup.py:找不到合适的 Requirements.parse('tensorflow') 发行版



tensorflow在我的项目setup.pyinstall_requires部分中列为要求。

当我尝试将我的项目安装到新的 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 "手动"安装张量流来解决这个问题:

$ 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'

这是在运行Ubuntu 18.04的戴尔笔记本电脑上没有GPU,所以解释器中显示的版本可能类似于tensorflow-cpu?如果我跑pip freeze我会看到tensorflow==2.0.0tensorflow-cpu==1.15.0rc2,这有点令人困惑......

这似乎是由使用 Python 版本 3.8 引起的,该版本目前是不受支持的 Python 版本。一旦我用Python 3.7版本创建了一个新的Anaconda环境,这个问题就消失了。

唯一剩下的问题是我在为包含张量流的项目运行pip install -e .时看到的此错误:

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.

因此,当版本2.1.0显示为已安装版本时,实际安装tensorflow-cpu版本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

最新更新