Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building wheel for cffi (setup.py) ... error while installing the packages from requirements.txt in django

I am trying to install a new Django project from git, I created a new virtual envt using python3(version: 3.8.5). When I try to install the required libraries in the requirements.txt, I get the following errors for cffi==1.11.5 package.

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, 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'"'"'))' 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, &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: Command errored out with exit status 1: /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'"'"'))' 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.

I will also add my requirements.txt file.

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

I have already followed some suggestions on stackoverflow but that doesn't seem to work. The things that I have tried already. Failed to install Python Cryptography package with PIP and setup.py

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

I am using Ubuntu. Please let me know what I am doing wrong.

like image 561
Shiwam Jaiswal Avatar asked Jun 23 '21 06:06

Shiwam Jaiswal


2 Answers

i had this problem and i solved by following:

i used sudo apt install --fix-broken for installing broken packages in my debian machine after that i used this command for installing essential packages : sudo apt-get install build-essential libssl-dev libffi-dev python-dev

and after that the problem solved.

like image 125
Amirreza Saki Avatar answered Oct 08 '22 22:10

Amirreza Saki


I just had the same issue. I was trying to install djoser and the same thing happened. To fix it I just simply downgrade my python from 3.10 to 3.9

like image 31
Melly Avatar answered Oct 08 '22 21:10

Melly