我使用的是 Ubuntu 22.04 LTS 版和 Python 3.10.4 版。我尝试为正在做的项目安装 requirements.txt,但遇到了标题中提到的问题。requirements.txt 文件指定 greenlet 为以下版本:greenlet==0.4.13。但是,我得到的错误如下:
Building wheels for collected packages: greenlet
Building wheel for greenlet (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [42 lines of output]
running bdist_wheel
running build
running build_ext
building 'greenlet' extension
creating build
creating build/temp.linux-x86_64-cpython-310
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.10 -c greenlet.c -o build/temp.linux-x86_64-cpython-310/greenlet.o
greenlet.c: In function ‘g_calltrace’:
greenlet.c:523:17: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘use_tracing’; did you mean ‘tracing’?
523 | tstate->use_tracing = 0;
| ^~~~~~~~~~~
| tracing
greenlet.c:526:17: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘use_tracing’; did you mean ‘tracing’?
526 | tstate->use_tracing = (tstate->tracing <= 0 &&
| ^~~~~~~~~~~
| tracing
greenlet.c: In function ‘g_initialstub’:
greenlet.c:810:25: warning: ‘PyEval_CallObjectWithKeywords’ is deprecated [-Wdeprecated-declarations]
810 | result = PyEval_CallObjectWithKeywords(
| ^~~~~~
In file included from /usr/include/python3.10/Python.h:130,
from greenlet.h:8,
from greenlet.c:5:
/usr/include/python3.10/ceval.h:17:43: note: declared here
17 | Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
greenlet.c: In function ‘green_dealloc’:
greenlet.c:984:33: error: lvalue required as left operand of assignment
984 | Py_REFCNT(self) = 1;
| ^
greenlet.c:1013:21: error: lvalue required as decrement operand
1013 | if (--Py_REFCNT(self) != 0) {
| ^~
greenlet.c:1017:41: error: lvalue required as left operand of assignment
1017 | Py_REFCNT(self) = refcnt;
| ^
greenlet.c:1021:25: error: ‘_Py_DEC_REFTOTAL’ undeclared (first use in this function); did you mean ‘_Py_DECREF’?
1021 | _Py_DEC_REFTOTAL;
| ^~~~~~~~~~~~~~~~
| _Py_DECREF
greenlet.c:1021:25: note: each undeclared identifier is reported only once for each function it appears in
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for greenlet
Running setup.py clean for greenlet
Failed to build greenlet
Installing collected packages: greenlet, geographiclib, chardet, Werkzeug, SQLAlchemy, requests, redis, python-json-logger, python-http-client, python-dateutil, protobuf, meinheld, gunicorn, geopy, sendgrid, mysql-connector-python, httpie
Running setup.py install for greenlet ... error
error: subprocess-exited-with-error
× Running setup.py install for greenlet did not run successfully.
│ exit code: 1
╰─> [44 lines of output]
running install
/home/shreeman/.local/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_ext
building 'greenlet' extension
creating build
creating build/temp.linux-x86_64-cpython-310
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.10 -c greenlet.c -o build/temp.linux-x86_64-cpython-310/greenlet.o
greenlet.c: In function ‘g_calltrace’:
greenlet.c:523:17: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘use_tracing’; did you mean ‘tracing’?
523 | tstate->use_tracing = 0;
| ^~~~~~~~~~~
| tracing
greenlet.c:526:17: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘use_tracing’; did you mean ‘tracing’?
526 | tstate->use_tracing = (tstate->tracing <= 0 &&
| ^~~~~~~~~~~
| tracing
greenlet.c: In function ‘g_initialstub’:
greenlet.c:810:25: warning: ‘PyEval_CallObjectWithKeywords’ is deprecated [-Wdeprecated-declarations]
810 | result = PyEval_CallObjectWithKeywords(
| ^~~~~~
In file included from /usr/include/python3.10/Python.h:130,
from greenlet.h:8,
from greenlet.c:5:
/usr/include/python3.10/ceval.h:17:43: note: declared here
17 | Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
greenlet.c: In function ‘green_dealloc’:
greenlet.c:984:33: error: lvalue required as left operand of assignment
984 | Py_REFCNT(self) = 1;
| ^
greenlet.c:1013:21: error: lvalue required as decrement operand
1013 | if (--Py_REFCNT(self) != 0) {
| ^~
greenlet.c:1017:41: error: lvalue required as left operand of assignment
1017 | Py_REFCNT(self) = refcnt;
| ^
greenlet.c:1021:25: error: ‘_Py_DEC_REFTOTAL’ undeclared (first use in this function); did you mean ‘_Py_DECREF’?
1021 | _Py_DEC_REFTOTAL;
| ^~~~~~~~~~~~~~~~
| _Py_DECREF
greenlet.c:1021:25: note: each undeclared identifier is reported only once for each function it appears in
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> greenlet
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
我已经在 Google 上搜索过此错误,但我尝试过的所有解决方案最终都不起作用。该错误要么与 ubuntu 或 python 的早期版本有关,但与我在此处描述的特定组合无关。欢迎任何帮助!
谢谢!Umesh
答案1
我有 python3.10,我正尝试从 requirements.txt 进行安装,其中包含“greenlet==0.4.17 ; python_version > '3.7'”。我的解决方案是将“greenlet==0.4.17”更改为“greenlet==1.1.0”,并且成功了。