47

I tried to install "scholarly" package, but I keep receiving this error:

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c build/temp.linux-x86_64-2.7/_openssl.c -o build/temp.linux-x86_64-2.7/build/temp.linux-x86_64-2.7/_openssl.o
build/temp.linux-x86_64-2.7/_openssl.c:434:30: fatal error: openssl/opensslv.h: No such file or directory
compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


Command "/usr/bin/python -u -c "import setuptools,tokenize;__file__='/tmp/pip-build-0OXGEx/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-EdgZGB-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-0OXGEx/cryptography/

Already tried the solutions in the following post, but it didnt work:

pip install lxml error

Community
  • 1
  • 1
msmazh
  • 785
  • 1
  • 9
  • 19

4 Answers4

115

I had the same problem. This one helped me:

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

If you are using python2, try to replace python3-dev with python-dev

andyw
  • 3,505
  • 2
  • 30
  • 44
6

In a newly created python 3.6, virtual environment and trying to run my setup.py of my module, the following command solved the error,

sudo apt-get install python3.6-dev

For me the error was,

... Python.h: No such file or directory
18 | #include "Python.h"
  |          ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

The remaining packages build-essential libssl-dev libffi-dev there were already installed from a previous time.

vpap
  • 1,389
  • 2
  • 21
  • 32
  • 1
    This solved the issue for me. My error was the same but occurred when I was installing `pyvoronoi` module for a pdf parser. – anurags May 24 '21 at 18:42
5

Install lib32ncurses5-dev:

sudo apt-get install lib32ncurses5-dev
CDspace
  • 2,639
  • 18
  • 30
  • 36
Rastin
  • 151
  • 1
  • 2
2

In my case the exception was:

Exception:

#include <snappy-c.h>
          ^~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit
status 1

And I solved it by installing these libraries:

sudo apt-get install libsnappy-dev

pip3 install python-snappy

Here is a great explanation about the cause of the exception and how we can get rid of that.

Phoenix
  • 3,996
  • 4
  • 29
  • 40