[英]Python3 Building a Pip Package 'setuptools is not defined'
I have configured my files according to the PyPi documentation for building a pip package and it worked once to build when I was creating my test server package. I made a couple of changes and am now trying to build again, but it is failing with the following error我已经根据用于构建 pip package 的 PyPi 文档配置了我的文件,并且在我创建测试服务器 package 时它构建了一次。我做了一些更改,现在正在尝试再次构建,但是它失败了跟随错误
Found existing installation: setuptools 44.0.0
Uninstalling setuptools-44.0.0:
Successfully uninstalled setuptools-44.0.0
Collecting setuptools>=42
Using cached setuptools-57.4.0-py3-none-any.whl (819 kB)
Collecting wheel
Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: setuptools, wheel
Successfully installed setuptools-57.4.0 wheel-0.36.2
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/pep517/in_process/_in_process.py", line 349, in <module>
main()
File "/usr/local/lib/python3.8/dist-packages/pep517/in_process/_in_process.py", line 331, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/local/lib/python3.8/dist-packages/pep517/in_process/_in_process.py", line 284, in get_requires_for_build_sdist
return hook(config_settings)
File "/tmp/build-env-s1i_b_fr/lib/python3.8/site-packages/setuptools/build_meta.py", line 159, in get_requires_for_build_sdist
return self._get_build_requires(config_settings, requirements=[])
File "/tmp/build-env-s1i_b_fr/lib/python3.8/site-packages/setuptools/build_meta.py", line 135, in _get_build_requires
self.run_setup()
File "/tmp/build-env-s1i_b_fr/lib/python3.8/site-packages/setuptools/build_meta.py", line 150, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 19, in <module>
packages=setuptools.find_packages(where="ontology_processing"),
NameError: name 'setuptools' is not defined
ERROR Backend subproccess exited when trying to invoke get_requires_for_build_sdist
I already have setup tools in both my pyproject.toml我的 pyproject.toml 中已经有了设置工具
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
and included it in my setup.py file并将其包含在我的 setup.py 文件中
from setuptools import setup, find_packages
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
setup(
name="ontology_processing",
version="1.0.0",
description="Climate Mind ontology processing code.",
author="ClimateMind",
author_email="omitted@omitted.com",
url="https://github.com/ClimateMind/climatemind-ontology-processing",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
package_dir={"": "src"},
packages=setuptools.find_packages(where="ontology_processing"),
python_requires=">=3.6",
)
I've tried changing the versions of setuptools, but nothing has worked so far.我试过更改 setuptools 的版本,但到目前为止没有任何效果。 I don't understand why this worked once, but is no longer working.
我不明白为什么这一次有效,但不再有效。 Any suggestions are appreciated.
任何建议表示赞赏。
Okay I screwed up.好吧,我搞砸了。
At the top I have在顶部我有
from setuptools import setup, find_packages
but I am not importing setuptools itself但我没有导入 setuptools 本身
I had the same error, but it was due to the inline comments I had written in the setup.cfg
file.我有同样的错误,但这是由于我在
setup.cfg
文件中写的内联注释。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.