Python 无法从 'setuptools' 包中导入名称

标签 python python-import setuptools importerror

我目前正在创建一个 python 库,需要使用“setuptools”包中的“find_namespace_packages”。但是,python 每次运行时都会抛出以下 ImportError 消息:

ImportError: cannot import name 'find_namespace_packages' from 'setuptools'
但是,从“setuptools”导入其他函数(如“setup”和“find_packages”)没有问题。
我该如何解决?
我已经多次卸载并重新安装“setuptools”并更新了 Spyder 和 Anaconda。
这里也是我的代码示例:
from setuptools import setup, find_namespace_packages

setup(

      name="sample",

      version="0.0.1",

      packages=find_namespace_packages()

      )
我目前使用的是 Python 3.7.5,而 setuptools 的版本是 49.6.0

最佳答案

正如问题的评论中提到的,解决方案是运行pip install -U setuptools然后重试安装所有软件包,例如pip install -e .

关于Python 无法从 'setuptools' 包中导入名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63628850/

相关文章:

python - 在 Mac OS X 上使用 NLTK 在 Celery 线程中使用 python-javabridge JVM 时出现 fatal error

python - 如何为 Homebrew 安装找到 python 和 python3 配置目录?

python - 按年份过滤日期,请帮我找出错误

python 无法导入时区,但可以导入日期时间

python - 为什么 setuptools 不理解 git+https URLs?

macos - Mac 上的 Python 3 setuptools

python - 使用 Tkinter 删除没有 overrideredirect() 的标题栏?

python - sklearn 无法导入名称 _ellipsoid

python - 如何解决 python 导入错误 - DLL 访问被拒绝

python - 使用安装工具清空目录