1

trainer在 AI 平台上安装软件包时出现此错误,

回溯(最后一次调用):文件“”,第 1 行,在文件“/tmp/pip-install-_u8thvm6/pycocotools/setup.py”中,第 2 行,来自 Cython.Build import cythonize ImportError: No module named '赛通'

虽然我已经包含'Cython'setup.py.

设置.py:

import setuptools

NAME = 'trainer'
VERSION = '1.0'
REQUIRED_PACKAGES = [
    'Cython', # Cython, mentioned before pycocotools
    'tensorflow-gpu',
    'google-cloud-storage',
    'gcsfs',
    'pycocotools'
]

setuptools.setup(
    name=NAME,
    version=VERSION,
    packages=setuptools.find_packages(),
    install_requires=REQUIRED_PACKAGES,
    include_package_data=True,
    description='Trainer package')

4

2 回答 2

1

通过在错误中添加这些行,setup.py解决了,

import setuptools

# Install cython before setup
import os                                       # <--- This line added
os.system('pip3 install --upgrade cython')      # <--- This line added

NAME = 'trainer'
VERSION = '1.0'
REQUIRED_PACKAGES = [
    'Cython', # Cython, mentioned before pycocotools
    'tensorflow-gpu',
    'google-cloud-storage',
    'gcsfs',
    'pycocotools'
]

setuptools.setup(
    name=NAME,
    version=VERSION,
    packages=setuptools.find_packages(),
    install_requires=REQUIRED_PACKAGES,
    include_package_data=True,
    description='Trainer package')
于 2019-12-04T06:18:50.147 回答
1

您需要在运行 setup.py 之前安装 cython。问题是在构建时需要 cython,而不是运行时,并且无法保证您列出的软件包的install_requires安装顺序。因此,当 pip 尝试安装时pycocotools,它尚未安装 cython 并中止。

于 2019-12-03T14:50:52.703 回答