首页 > 解决方案 > 无法使用 setup.py 中的 Github Actions 在 Ubuntu 中安装 Tensorflow 2.2.0rc0

问题描述

当我尝试从 Github Actions Workflow 运行安装tensorflow>=2.2.0rc0时,输出setup.py会发送给我:python setup.py install

Searching for tensorflow>=2.2.0rc0
Reading https://pypi.org/simple/tensorflow/
No local packages or working download links found for tensorflow>=2.2.0rc0
error: Could not find suitable distribution for Requirement.parse('tensorflow>=2.2.0rc0')
##[error]Process completed with exit code 1.

这是我的 Github Action 工作流程:

name: Test Deblurrer

on: 
  push:
    branches:
    - master
    - development 
  pull_request:
    branches:
    - master
    - development

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version: [3.7]

    steps:
    - uses: actions/checkout@v1
    - name: Setup Python ${{ matrix.python-version }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        sudo apt-get install libpq-dev python-dev
        python -m pip install --upgrade pip
        python setup.py install
        pip install pytest

    - name: Test with pytest
      run: |
        PYTHONPATH=${PYTHONPATH}:/home/runner/work/deep-deblurring/deep-deblurring/backend:$(pwd)
        pytest

接下来是我的 setup.py:

#!/usr/bin/python
# coding=utf-8

"""Setup and install the package and all the dependencies."""

from setuptools import setup, find_packages

with open('requirements.txt') as pro:
    INSTALL_REQUIRES = pro.read().split('\n')

setup(
    author='Whitman Bohorquez, Mo Rebaie',
    author_email='whitman-2@hotmail.com',
    name='deblurrer',
    license='MIT',
    description='Image Deblurring using Deep Learning Architecture',
    version='1.0.0',
    url='',
    packages=find_packages(),
    include_package_data=True,
    python_requires='>=3.6',
    install_requires=INSTALL_REQUIRES,
    classifiers=[
        'Development Status :: Alpha',
        'Programming Language :: Python',
        'Programming Language :: Python :: 3.6',
        'Intended Audience :: Developers',
    ],
)

最后,我的 requirements.txt:

grpcio == 1.27.2
kaggle
numpy
tensorflow >= 2.2.0rc0
pandas

我不明白为什么在 Github Actions 上会发生这种情况,但是在 Windows 10 上本地安装时,它可以按预期工作。

提前致谢!

PD:当我pip install tensorflow==2.2.0rc0直接在 Github Action Workflow 上执行而不是在它内部python setup.py install时,它也可以工作。所以这setup.py不仅适用于 Ubuntu,而且仅适用于 Ubuntu

标签: pythontensorflowpipgithub-actions

解决方案


问题在于setuptools版本过时。从 2.0 开始,只在 Linux 上提供带有标签的tensorflow轮子。在 42.0.0中添加了支持,因此升级将解决问题:manylinux2010setuptoolsmanylinux2010 setuptools

$ pip install setuptools>=42.0.0

推荐阅读