为 cffi (setup.py) 构建轮子……从 django

问题描述

我正在尝试从 git 安装一个新的 Django 项目,我使用创建了一个新的虚拟环境 python3(版本:3.8.5)。当我尝试在 requirements.txt 中安装所需的库时,我收到 cffi==1.11.5 包的以下错误

Building wheels for collected packages: cffi
  Building wheel for cffi (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /home/jessica/Documents/FreelanceProjects/crowdbuy/env/bin/python3 -u -c 'import io,os,sys,setuptools,tokenize; sys.argv[0] = '"'"'/tmp/pip-install-71z3f0vy/cffi_136411f3ae2d49e4b889de52edc8d550/setup.py'"'"'; __file__='"'"'/tmp/pip-install-71z3f0vy/cffi_136411f3ae2d49e4b889de52edc8d550/setup.py'"'"';f = getattr(tokenize,'"'"'open'"'"',open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-1y2in5qm
       cwd: /tmp/pip-install-71z3f0vy/cffi_136411f3ae2d49e4b889de52edc8d550/
  Complete output (49 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-3.8
  creating build/lib.linux-x86_64-3.8/cffi
  copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/model.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/cparser.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/verifier.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/__init__.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/commontypes.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/lock.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/api.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/recompiler.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/error.py -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/_embedding.h -> build/lib.linux-x86_64-3.8/cffi
  copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.8/cffi
  running build_ext
  building '_cffi_backend' extension
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/c
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/home/jessica/Documents/FreelanceProjects/crowdbuy/env/include -I/usr/include/python3.8 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.8/c/_cffi_backend.o
  c/_cffi_backend.c: In function ‘b_do_dlopen’:
  c/_cffi_backend.c:4197:31: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   4197 |         *p_printable_filename = PyText_AsUTF8(s);
        |                               ^
  c/_cffi_backend.c: In function ‘b_callback’:
  c/_cffi_backend.c:5911:5: warning: ‘ffi_prep_closure’ is deprecated: use ffi_prep_closure_loc instead [-Wdeprecated-declarations]
   5911 |     if (ffi_prep_closure(closure,&cif_descr->cif,|     ^~
  In file included from c/_cffi_backend.c:15:
  /usr/include/x86_64-linux-gnu/ffi.h:334:1: note: declared here
    334 | ffi_prep_closure (ffi_closure*,| ^~~~~~~~~~~~~~~~
  In file included from c/cffi1_module.c:20,from c/_cffi_backend.c:7370:
  c/call_python.c: In function ‘_get_interpstate_dict’:
  c/call_python.c:20:30: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
     20 |     builtins = tstate->interp->builtins;
        |                              ^~
  error: command 'x86_64-linux-gnu-gcc' Failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for cffi
  Running setup.py clean for cffi
Failed to build cffi
Installing collected packages: pycparser,urllib3,six,pytz,jdcal,idna,et-xmlfile,chardet,cffi,certifi,asn1crypto,xlwt,xlrd,unicodecsv,text-unidecode,requests,PyYAML,python-dateutil,openpyxl,odfpy,oauthlib,Django,defusedxml,cryptography,tablib,sqlparse,requests-oauthlib,python3-openid,pyOpenSSL,Pillow,phonenumberslite,pbr,Faker,django-ranged-response,django-js-asset,diff-match-patch,Babel,Unidecode,sorl-thumbnail,PyMysqL,purl,paypalrestsdk,mock,future,factory-boy,django-widget-tweaks,django-treebeard,django-tables2,django-simple-captcha,django-phonenumber-field,django-paypal,django-mptt,django-modeltranslation,django-import-export,django-haystack,django-filter,django-extra-views,django-debug-toolbar,django-crontab,django-countries,django-anymail,django-allauth,django-admin-honeypot
    Running setup.py install for cffi ... error
    ERROR: Command errored out with exit status 1:
     command: /home/jessica/Documents/FreelanceProjects/crowdbuy/env/bin/python3 -u -c 'import io,'"'"'exec'"'"'))' install --record /tmp/pip-record-yjyoqxw6/install-record.txt --single-version-externally-managed --compile --install-headers /home/jessica/Documents/FreelanceProjects/crowdbuy/env/include/site/python3.8/cffi
         cwd: /tmp/pip-install-71z3f0vy/cffi_136411f3ae2d49e4b889de52edc8d550/
    Complete output (49 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.8
    creating build/lib.linux-x86_64-3.8/cffi
    copying cffi/cffi_opcode.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/model.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/vengine_cpy.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/cparser.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/backend_ctypes.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/verifier.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/__init__.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/commontypes.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/vengine_gen.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/lock.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/setuptools_ext.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/api.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/ffiplatform.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/recompiler.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/error.py -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/_cffi_include.h -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/parse_c_type.h -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/_embedding.h -> build/lib.linux-x86_64-3.8/cffi
    copying cffi/_cffi_errors.h -> build/lib.linux-x86_64-3.8/cffi
    running build_ext
    building '_cffi_backend' extension
    creating build/temp.linux-x86_64-3.8
    creating build/temp.linux-x86_64-3.8/c
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/home/jessica/Documents/FreelanceProjects/crowdbuy/env/include -I/usr/include/python3.8 -c c/_cffi_backend.c -o build/temp.linux-x86_64-3.8/c/_cffi_backend.o
    c/_cffi_backend.c: In function ‘b_do_dlopen’:
    c/_cffi_backend.c:4197:31: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     4197 |         *p_printable_filename = PyText_AsUTF8(s);
          |                               ^
    c/_cffi_backend.c: In function ‘b_callback’:
    c/_cffi_backend.c:5911:5: warning: ‘ffi_prep_closure’ is deprecated: use ffi_prep_closure_loc instead [-Wdeprecated-declarations]
     5911 |     if (ffi_prep_closure(closure,|     ^~
    In file included from c/_cffi_backend.c:15:
    /usr/include/x86_64-linux-gnu/ffi.h:334:1: note: declared here
      334 | ffi_prep_closure (ffi_closure*,| ^~~~~~~~~~~~~~~~
    In file included from c/cffi1_module.c:20,from c/_cffi_backend.c:7370:
    c/call_python.c: In function ‘_get_interpstate_dict’:
    c/call_python.c:20:30: error: dereferencing pointer to incomplete type ‘PyInterpreterState’ {aka ‘struct _is’}
       20 |     builtins = tstate->interp->builtins;
          |                              ^~
    error: command 'x86_64-linux-gnu-gcc' Failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/jessica/Documents/FreelanceProjects/crowdbuy/env/bin/python3 -u -c 'import io,'"'"'exec'"'"'))' install --record /tmp/pip-record-yjyoqxw6/install-record.txt --single-version-externally-managed --compile --install-headers /home/jessica/Documents/FreelanceProjects/crowdbuy/env/include/site/python3.8/cffi Check the logs for full command output.

我还将添加我的 requirements.txt 文件

asn1crypto==0.24.0
Babel==2.5.3
certifi==2018.1.18
cffi==1.11.5
chardet==3.0.4
cryptography==2.2.2
defusedxml==0.5.0
diff-match-patch==20121119
Django==2.0.4
django-admin-honeypot==1.1.0
django-allauth==0.35.0
django-anymail==2.0
django-countries==5.3
django-debug-toolbar==1.9.1
django-extra-views==0.6.4
django-filter==1.1.0
django-haystack==2.8.1
django-import-export==1.0.1
django-js-asset==1.0.0
django-modeltranslation==0.12.2
django-mptt==0.9.0
django-paypal==0.5.0
django-phonenumber-field==1.3.0
django-ranged-response==0.2.0
django-simple-captcha==0.5.6
django-tables2==1.16.0
django-treebeard==4.3
django-widget-tweaks==1.4.2
et-xmlfile==1.0.1
factory-boy==2.10.0
Faker==0.8.13
future==0.16.0
idna==2.6
jdcal==1.4
mock==2.0.0
oauthlib==2.0.7
odfpy==1.3.6
openpyxl==2.5.4
paypalrestsdk==1.13.1
pbr==4.0.2
phonenumberslite==8.9.3
Pillow==5.1.0
purl==1.4
pycparser==2.18
PyMysqL==0.8.0
pyOpenSSL==17.5.0
python-dateutil==2.7.2
python3-openid==3.1.0
pytz==2018.4
PyYAML==3.12
requests==2.18.4
requests-oauthlib==0.8.0
six==1.11.0
sorl-thumbnail==12.4.1
sqlparse==0.2.4
tablib==0.12.1
text-unidecode==1.2
unicodecsv==0.14.1
Unidecode==0.4.21
urllib3==1.22
xlrd==1.1.0
xlwt==1.3.0
django-crontab

我已经遵循了有关 stackoverflow 的一些建议,但这似乎不起作用。 我已经尝试过的事情。 Failed to install Python Cryptography package with PIP and setup.py

sudo apt-get install build-essential libssl-dev libffi-dev python3-dev

我正在使用 Ubuntu。请让我知道我做错了什么。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)