fatal error: 'openssl/e_os2.h' file not found in pypy - python

When I Run Command pypy -m pip install cryptography
then I have got below Errors:
cc -arch x86_64 -O2 -fPIC -Wimplicit -I/opt/pypy-5.0.1/include -c build/temp.macosx-10.10-x86_64-2.7/_openssl.c -o build/temp.macosx-10.10-x86_64-2.7/build/temp.macosx-10.10-x86_64-2.7/_openssl.o
build/temp.macosx-10.10-x86_64-2.7/_openssl.c:423:10: fatal error: 'openssl/e_os2.h' file not found
#include
^
1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/usr/local/bin/pypy -u -c "import setuptools, tokenize;file='/private/var/folders/_t/8l_tq9210xl4bzlhkspnv8br0000gn/T/pip-build-Gjhf5l/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /var/folders/_t/8l_tq9210xl4bzlhkspnv8br0000gn/T/pip-6_y8I9-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/_t/8l_tq9210xl4bzlhkspnv8br0000gn/T/pip-build-Gjhf5l/cryptography/

On OS X PyPy you'll need to brew install openssl (or port install or whatever) and then run the following command:
LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography
If you use ports modify the paths to point at the proper location.

if you pc is mac,please configure as follows:
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
and amazingly,it works fine for me.

Cryptography requires compiling C Extensions.
Depending on the the platform you're on, you should install python-dev and gcc prior to installing cryptography:
debian: sudo apt-get install python-dev gcc
rhel: sudo yum install python-devel gcc
windows: you need to install the Python C++ Runtime (https://www.microsoft.com/en-us/download/details.aspx?id=44266)

Related

portaudio.h: No such file or directory

I got the following error while trying to install pyaudio using pip3 in ubuntu 16.04:
Collecting pyaudio
Downloading PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/pyaudio/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-v55chjee-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
copying src/pyaudio.py -> build/lib.linux-x86_64-3.5
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.5/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-mxgvewdb/pyaudio/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-v55chjee-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-mxgvewdb/pyaudio/
This should help
$ sudo apt-get install portaudio19-dev python-pyaudio python3-pyaudio
Tested on Ubuntu 18.04, Python 3.7.2, pyaudio 0.2.11
Added 8th of Jan 2021:
On Ubuntu 20.04 you have to use:
$ sudo apt install portaudio19-dev python3-pyaudio
For Windows, here's what I've been going through...
There're several ways to install PortAudio
vcpkg, https://vcpkg.info/port/portaudio
winget, https://winget.run/pkg/intxcc/pyaudio
Or, manually build from source and install manually
download source, http://files.portaudio.com/download.html
build with cmake, with the matching compiler(msvc/mingw) and arch(x64/x86) to your Python
put "portaudio.h" into python-include directory, e.g. c:\Python38-32\include\
put "portaudio.lib into python-lib directory, e.g. c:\Python38-32\libs
Arrh!
the "min()" macro in pyaudio's soucefile _portaudiomodule.c is troublesome, comment it out manually
pip install pyaudio --no-clean
find _portaudiomodule.c in the temp directory and manually comment-out the "min()" macro e.g. c:\Temp\pip-install-yysb8bme\pyaudio_c92585\src\_portaudiomodule.c
pip install from that directorye.g. pip install c:\Temp\pip-install-yysb8bme\pyaudio_c92585\
Or,3rd party wheels
this answer said:
pip install pipwinpipwin install pyaudio
For MacOS (Intel/Apple Silicon):
Step 1:
brew install portaudio
Step 2:
brew --prefix portaudio
The output provided from the above command, will be required in Step 3, which will look something similar to /opt/homebrew/opt/portaudio
Step 3:
Create .pydistutils.cfg in your home directory
sudo nano ~/.pydistutils.cfg
then paste the following in the file, save and exit
[build_ext]
include_dirs=<PATH FROM STEP 2>/include/
library_dirs=<PATH FROM STEP 2>/lib/
Step 4:
pip3 install pyaudio
For Centos7/RHEL:
yum install portaudio-devel alsa-lib-devel portaudio
pip install pyaudio --user

Error while upgrading PyAudio to latest version

I have PyAudio (0.2.7) installed in my system.
When I tried to upgrade using
sudo pip install pyaudio --upgrade
I'm getting this.
Downloading/unpacking pyaudio from https://pypi.python.org/packages/44/39/f3b9b16d32cc8588fa06bb2e813cea35363f5502117cd6cc7f619b556d9f/PyAudio-0.2.10.tar.gz#md5=b65354d997fa00a9166f8dbcb83075e6
Downloading PyAudio-0.2.10.tar.gz (287kB): 287kB downloaded
Running setup.py (path:/tmp/pip_build_root/pyaudio/setup.py) egg_info for package pyaudio
Installing collected packages: pyaudio
Found existing installation: PyAudio 0.2.7
Not uninstalling PyAudio at /usr/lib/python3/dist-packages, owned by OS
.......
.......
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.4/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Can't roll back PyAudio; was not uninstalled
Cleaning up...
Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ih3i9qsm-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/pyaudio
Storing debug log for failure in /home/jobin/.pip/pip.log
I'm using elementary os 14.04
What is the problem here?
Thanks #Cristian Ciupitu for the advice to install portaudio-dev.
But portaudio-dev did not installed with sudo apt-get install portaudio-dev in my case.
I got
E: Unable to locate package portaudio-dev
How this was solved
Downloaded the .tgz of portaudio file from here
Then Extract the downloaded file.
cd to the extracted folder.
Then ./configure && make
Now do sudo make install
Then upgrade pyaudio by sudo pip install pyaudio --upgrade
Now pyaudio was successfully installed.
run in terminal:
$ sudo apt install python3-pyaudio
This worked for me
sudo apt-get install portaudio19-dev python-pyaudio
then do this
pip install PyAudio
You need to install the portaudio-dev package, for example by running:
sudo apt-get install portaudio-dev
pip install pyaudio --upgrade
pip install pyaudio --user

installing python-ldap on windows with cygwin (fails on gcc)

I have a virtual windows machine where I'm trying to install Python packages.
I've never used Windows before, so I started by installing Cygwin and used that to install the other packages I'd need.
At first I tried installing Python2.7 from Python.org, but eventually read that it was better for using GCC to use the one from Cygwin.
$ python -c "import math; print math.sqrt(4)" # seems like all is well
Here's the install line (setup-x86_64.exe is the Cygwin installer binary):
$ ./setup-x86_64.exe -q -P wget -P gcc-g++ -P make -P python2.7
$ pip --version
pip 9.0.1 from /usr/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
$ which python
/usr/bin/python
$ which pip
/usr/bin/pip
$ which g++
/usr/bin/g++
$ which gcc
/usr/bin/gcc
Then I ran the following:
$ pip install python-ldap
...lots of lines...
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-D1mVYX/python-ldap/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-3_5lF9-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-D1mVYX/python-ldap/
This is weird since I know (from above) that gcc & g++ are working just fine!
Anyone know how I can install python-ldap properly with pip?
Thanks!

ReviewBoard pip installation failure

I am trying to install ReviewBoard on 14.04.1-Ubuntu and I get the error below. I have used commands:
sudo apt-get install python-setuptools python-dev memcached patch libjpeg-dev
sudo pip install -U pip
sudo easy_install pip
sudo apt-get install python-mysqldb
sudo pip install ReviewBoard
File "/usr/lib/python2.7/distutils/command/build_ext.py", line 337, in run self.build_extensions()
File "/tmp/pip-build-84i3OO/Pillow/setup.py", line 512, in build_extensions' using --disable-%s, aborting' % (f, f))
ValueError: zlib is required unless explicitly disabled using --disable-zlib, aborting
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-84i3OO/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-5lU4Yb-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-84i3OO/Pillow/
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages
/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Are there any ideas why does it happen and how to solve it?
EDIT
Installed pillow (https://discuss.erpnext.com/t/new-python-dependency-pillow-if-you-get-error-during-update-see-this-post/7900):
sudo apt-get install -y libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
sudo pip install pillow
Now getting:
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 - Wall -Wstrict-prototypes -fPIC -DUSE__THREAD -I/usr/include/ffi -I/usr/include/l ibffi -I/usr/include/python2.7 -c c/_cffi_backend.c -o build/temp.linux-x86_64-2 .7/c/_cffi_backend.o
c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory
#include <ffi.h>
^
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-hB90D2/cffi/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-CCyW5e-record/install-record.txt --single-version-externally-managed --compile"
failed with error code 1 in /tmp/pip-build-hB90D2/cffi/
Have you tried to install libffi-devel
apt-get install libffi-dev
Sometime to fix pip issues its useful to install build-essential and python-dev
apt-get install python-dev && apt-get install build-essential
Good luck!
Installed pillow using (https://discuss.erpnext.com/t/new-python-dependency-pillow-if-you-get-error-during-update-see-this-post/7900):
sudo apt-get install -y libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
sudo pip install pillow
Then ccfi using (Failed to install Python Cryptography package with PIP and setup.py):
sudo apt-get install libffi-dev libssl-dev libpython2.7-dev
sudo pip install cryptography
sudo pip install cffi
To get Python 2.7 Fabric 1.13 on CentOS 7 working I had to install openssl-devel first.
Complete Error:
#include <openssl/opensslv.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-2hTQUe/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-mqFBbh-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-2hTQUe/cryptography/
Solution:
sudo yum install -y gcc make openssl openssl-devel
sudo pip install fabric

gevent/libevent.h:9:19: fatal error: event.h: No such file or directory

I was trying to work on Pyladies website on my local folder. I cloned the repo, (https://github.com/pyladies/pyladies) ! and created the virtual environment. However when I do the pip install -r requirements, I am getting this error
Installing collected packages: gevent, greenlet
Running setup.py install for gevent
building 'gevent.core' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/opt/local/include -fPIC -I/usr/include/python2.7 -c gevent/core.c -o build/temp.linux-i686-2.7/gevent/core.o
In file included from gevent/core.c:253:0:
gevent/libevent.h:9:19: fatal error: event.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /home/akoppad/virt/pyladies/bin/python -c "import setuptools;__file__='/home/akoppad/virt/pyladies/build/gevent/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-4MSIGy-record/install-record.txt --install-headers /home/akoppad/virt/pyladies/include/site/python2.7:
running install
running build
running build_py
running build_ext
building 'gevent.core' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -I/opt/local/include -fPIC -I/usr/include/python2.7 -c gevent/core.c -o build/temp.linux-i686-2.7/gevent/core.o
In file included from gevent/core.c:253:0:
gevent/libevent.h:9:19: fatal error: event.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /home/akoppad/virt/pyladies/bin/python -c "import setuptools;__file__='/home/akoppad/virt/pyladies/build/gevent/setup.py'; exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-4MSIGy-record/install-record.txt --install-headers /home/akoppad/virt/pyladies/include/site/python2.7 failed with error code 1 in /home/akoppad/virt/pyladies/build/gevent
Storing complete log in /home/akoppad/.pip/pip.log.
I tried doing this,
sudo port install libevent
CFLAGS="-I /opt/local/include -L /opt/local/lib" pip install gevent
It says port command not found.
I am not sure how to proceed with this. Thanks!
I had the same problem and just as the other answer suggested I had to install "libevent". It's apparently not called "libevent-devel" anymore (apt-get couldn't find it) but doing:
$ apt-cache search libevent
listed a bunch of available packages.
$ apt-get install libevent-dev
worked for me.
I think you just forget to install the "libevent" in the environment. If you are on a OSX machine, please try to install brew here http://mxcl.github.io/homebrew/ and use brew install libevent to install the dependency. If you are on an ubuntu machine, you can try apt-get to install the corresponding library.
I had this issue while trying to
pip install Flask-Sockets
and
sudo apt-get install libevent-dev
worked for me
yum install libevent-*
This command works for me because I am on centos.
I ran into this error on MacOS 10.10.1 (Yosemite) running pip install. The solution for me was to add the path to libevent which pip was missing. These are C files, and CFLAGS and DFLAGS are bash environment variables that let pip know where to find these files. On my system, libevent is found at /usr/local/include/event2.
$ CFLAGS=-I/usr/local/include/event2 DFLAGS=-L/usr/local/lib pip install -r requires.txt

Categories