首页 > 解决方案 > 在尝试安装 dm-sonnet 包时,我在 python-2.7 中面临“从 setuptools import find_namespace_packages”错误。任何可能的解决方案?

问题描述

我需要对某些脚本使用 python-2.7,setuptools==39.1.0,我无法 pip install dm-sonnet,setuptools 中应该有 find_namespace_packages 吗?它不在此 setuptools(或 v44)错误消息中:

ERROR: Command errored out with exit status 1:
         command: /home/russo/anaconda3/envs/russo2/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-9l072x/dm-sonnet/setup.py'"'"'; __file__='"'"'/tmp/pip-install-9l072x/dm-sonnet/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-9l072x/dm-sonnet/pip-egg-info
             cwd: /tmp/pip-install-9l072x/dm-sonnet/
        Complete output (5 lines):
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-install-9l072x/dm-sonnet/setup.py", line 7, in <module>
            from setuptools import find_namespace_packages
        ImportError: cannot import name find_namespace_packages
        ----------------------------------------
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

标签: pythonpython-2.7setuptools

解决方案


dm-sonnet需要 Python 3。你不能在 Python 2 中使用它。

在提交00612ca 中 setup.py使用find_packages. 您可以使用 Python 2.7 试用此版本。它可能是1.36或更早的版本。尝试

pip2 install dm-sonnet==1.36

或者

pip2 install 'dm-sonnet<2'

推荐阅读