When I try to install a python package (cryptography in this case) in the Linux terminal, I get an error. I am using Python version 3.8. Here's the code:
Input:
python3.8 -m pip install cryptography
or pip install cryptography
Output (anything after "Installing build dependencies ... error" is in RED):
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting cryptography
Using cached cryptography-36.0.1.tar.gz (572 kB)
Installing build dependencies ... error
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3.8
/usr/local/lib/python3.8/site-packages/pip install --ignore-installed
--no-user --prefix /tmp/pip-build-env-j3i9og4s/overlay
--no-warn-script-location --no-binary :none: --only-binary :none: -i
https://pypi.org/simple --extra-index-url
https://www.piwheels.org/simple -- 'setuptools>=40.6.0' wheel
'cffi>=1.12; platform_python_implementation != '"'"'PyPy'"'"''
'setuptools-rust>=0.11.4'
cwd: None
Complete output (26 lines):
Looking in indexes: https://pypi.org/simple,
https://www.piwheels.org/simple, https://www.piwheels.org/simple
Collecting setuptools>=40.6.0
Using cached setuptools-60.9.3-py3-none-any.whl (1.1 MB)
Collecting wheel
Using cached wheel-0.37.1-py2.py3-none-any.whl (35 kB)
Collecting cffi>=1.12
Using cached cffi-1.15.0.tar.gz (484 kB)
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3.8 -c 'import sys, setuptools,
tokenize; sys.argv[0] =
'"'"'/tmp/pip-install-9sokml3p/cffi/setup.py'"'"';
__file__='"'"'/tmp/pip-install-9sokml3p/cffi/setup.py'"'"';f=getattr(tokenize,
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))'
egg_info --egg-base /tmp/pip-pip-egg-info-5ylb3zxi
cwd: /tmp/pip-install-9sokml3p/cffi/
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py",
line 19, in <module>
from setuptools.dist import Distribution
File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py",
line 34, in <module>
from setuptools import windows_support
File "/usr/local/lib/python3.8/site-packages/setuptools/windows_support.py",
line 2, in <module>
import ctypes
File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py
egg_info Check the logs for full command output.
WARNING: You are using pip version 20.1.1; however, version 22.0.3
is available.
You should consider upgrading via the '/usr/local/bin/python3.8 -m
pip install --upgrade pip' command.
----------------------------------------
ERROR: Command errored out with exit status 1:
/usr/local/bin/python3.8 /usr/local/lib/python3.8/site-packages/pip
install --ignore-installed --no-user --prefix
/tmp/pip-build-env-j3i9og4s/overlay --no-warn-script-location
--no-binary :none: --only-binary :none: -i https://pypi.org/simple
--extra-index-url https://www.piwheels.org/simple --
'setuptools>=40.6.0' wheel 'cffi>=1.12; platform_python_implementation
!= '"'"'PyPy'"'"'' 'setuptools-rust>=0.11.4' Check the logs for full
command output.
I don't really understand what this means, and I'd like some assistance installing a package and trying to fix this error. Thanks! -Shane
EDIT: I found near the beginning the text 'Command errored out with exit status 1' EDIT: I have installed libffi-dev.
CodePudding user response:
Looks like you may need to install libffi-dev. I'm not sure your distro, but it'll be there. Distro is raspbian.
Install with:
apt-get install libffi-dev
There are other questions that looks similar since they have the _ctypes
issue, but I won't mark this as a duplicate since your question is exactly the same. I think the underlying root cause is probably the same. See here and here.
CodePudding user response:
Solved by upgrading pip to pip3 using sudo apt-get -y install python3-pip
.