Reputation: 23
I'm trying to install the cryptography python library using pip (so I can use paramiko), but I'm getting a gcc error.
Some background: this is on a CentOS 5.11 VM that I was given with Python 2.4.3 installed. I installed Python 2.7.12 alongside it, and had to struggle a little bit to get all the dependencies for cryptography installed.
When I run the command
sudo pip2.7 install cryptography
I first get an SNIMissingWarning error (which I think is tangential, but I'll give details at the end of the question, in case it's not). Then I get several hundred lines of install logs, finally ending with:
build/temp.linux-i686-2.7/_openssl.c:72077: error: storage class specified for parameter ‘_cffi_type_context’
build/temp.linux-i686-2.7/_openssl.c:72077: error: parameter ‘_cffi_type_context’ is initialized
build/temp.linux-i686-2.7/_openssl.c:72120: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘{’ token
build/temp.linux-i686-2.7/_openssl.c:72122: error: old-style parameter declarations in prototyped function definition
build/temp.linux-i686-2.7/_openssl.c:591: error: parameter name omitted
build/temp.linux-i686-2.7/_openssl.c:72122: error: expected ‘{’ at end of input
error: command 'gcc' failed with exit status 1
Command "/usr/local/bin/python2.7 -u -c "import setuptools, tokenize;file='/tmp/pip-build-RGpvd5/cryptography/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-kwpB5q-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-RGpvd5/cryptography/
Since it's a gcc error, I'm not sure what to do. I looked for information about it, but I don't know much about C, so the answers didn't mean much to me. I couldn't find anything relating to installing cryptography for python discussing this specific error.
Any ideas what may be happening?
In more detail, the SNIMissingWarning message I get is:
/usr/local/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/vendor/requests/packages/urllib3/util/ssl.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
Using cached cryptography-1.6.tar.gz
The readthedocs.io link has this to say about the error: "This happens on Python 2 versions older than 2.7.9. These older versions lack SNI support." Since I am using 2.7.12, hopefully that's not a problem. It further suggests installing urllib3 with the secure option, which I tried, using
pip2.7 install urllib3[secure]
This automatically attempted to install cryptography, and that failed with a gcc error, the same way as before.
Upvotes: 2
Views: 4303
Reputation: 9701
This has happened to me with Python 3.6 on several occasions. The fix I found to work on every occasion is:
sudo apt update
sudo apt install gcc libffi-dev libbz2-dev
Then, if you get a This package requires Rust >= x.x.x
complaint you might need:
sudo apt install rustc
pip install rust
Then carry on with:
pip install cryptography
If this fails with ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly
, use the following as mentioned in this answer. In my case, cryptography 3.4.7
failed with this error.
pip install cryptography==3.1.1
Upvotes: 1
Reputation: 537
I remember having difficulty with this as well. From what I remember, the command that worked for me was: sudo python -m pip install cryptography
If Python 2.7 isn't default on your system, you may need to use: sudo python2.7 -m pip install cryptography
Edit:
Thought I'd also add this. Try reinstalling gcc. Since you're on CentOS: $ sudo yum reinstall gcc
Upvotes: 1