Trying to install m2crypto in a Dockerfile:
FROM python:3.7
RUN pip install m2crypto
I'm getting the following error output (truncated):
Step 7/8 : RUN pip install m2crypto
---> Running in 1204096f1488
Collecting m2crypto
Downloading https://files.pythonhosted.org/packages/23/93/1c1a887f956ec38d691af110d38059e234fc941019e0c074a66a10846813/M2Crypto-0.34.0.tar.gz (1.1MB)
Building wheels for collected packages: m2crypto
Building wheel for m2crypto (setup.py): started
Building wheel for m2crypto (setup.py): finished with status 'error'
ERROR: Complete output from command /usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-ptf_nqd5/m2crypto/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-w9seu9sh --python-tag cp37:
ERROR: running bdist_wheel
...
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include/python3.7m -I/tmp/pip-install-ptf_nqd5/m2crypto/SWIG -c SWIG/_m2crypto_wrap.c -o build/temp.linux-x86_64-3.7/SWIG/_m2crypto_wrap.o -Wno-deprecated-declarations -DTHREADING
SWIG/_m2crypto_wrap.c: In function ‘_wrap__STACK_num_set’:
SWIG/_m2crypto_wrap.c:9506:19: error: dereferencing pointer to incomplete type ‘struct stack_st’
if (arg1) (arg1)->num = arg2;
^~
... lots more errors ...
ERROR: Command "/usr/local/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-ptf_nqd5/m2crypto/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-record-xq22_pd8/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-ptf_nqd5/m2crypto/
Full output at https://pastebin.com/3bmdGvdx.
Am I doing something wrong?
Solved it on my own by following the installation instructions:
FROM python:3.7
RUN apt-get update
RUN apt-get install -y build-essential
RUN apt-get install -y python3-dev
RUN apt-get install -y swig
RUN pip install m2crypto
libssl-dev is mentioned in the instructions but is already present. apt-get update is required, or build-essential won't be found. -y is required because python3-dev is large, and apt-get install will otherwise prompt "do you want to install? [Y/n]".
I'm sure many other variations of this will also work, using other base images. But this does work.
Related
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
I want to install pyHive package in ubuntu. Using this step:-
sudo apt-get install gcc
sudo apt-get install libsasl2-dev
pip install sasl
pip install thrift
pip install thrift-sasl
pip install PyHive
but when i install sasl package it's given me error
Using cached sasl-0.2.1.tar.gz (30 kB)
Requirement already satisfied: six in /home/shivam_gupta/Documents/pip3-venv/lib/python3.7/site-packages (from sasl) (1.14.0)
Installing collected packages: sasl
Running setup.py install for sasl ... error
ERROR: Command errored out with exit status 1:
command: /home/shivam_gupta/Documents/pip3-venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vokx0cvb/sasl/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vokx0cvb/sasl/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-record-hqi5nw58/install-record.txt --single-version-externally-managed --compile --install-headers /home/shivam_gupta/Documents/pip3-venv/include/site/python3.7/sasl
cwd: /tmp/pip-install-vokx0cvb/sasl/
Complete output (32 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/sasl
copying sasl/__init__.py -> build/lib.linux-x86_64-3.7/sasl
running egg_info
writing sasl.egg-info/PKG-INFO
writing dependency_links to sasl.egg-info/dependency_links.txt
writing requirements to sasl.egg-info/requires.txt
writing top-level names to sasl.egg-info/top_level.txt
reading manifest file 'sasl.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'sasl.egg-info/SOURCES.txt'
copying sasl/saslwrapper.cpp -> build/lib.linux-x86_64-3.7/sasl
copying sasl/saslwrapper.h -> build/lib.linux-x86_64-3.7/sasl
copying sasl/saslwrapper.pyx -> build/lib.linux-x86_64-3.7/sasl
running build_ext
building 'sasl.saslwrapper' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/sasl
gcc -pthread -B /home/shivam_gupta/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Isasl -I/home/shivam_gupta/Documents/pip3-venv/include -I/home/shivam_gupta/anaconda3/include/python3.7m -c sasl/saslwrapper.cpp -o build/temp.linux-x86_64-3.7/sasl/saslwrapper.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
In file included from sasl/saslwrapper.cpp:254:0:
sasl/saslwrapper.h: In member function ‘void saslwrapper::ClientImpl::interact(sasl_interact_t*)’:
sasl/saslwrapper.h:437:11: warning: unused variable ‘input’ [-Wunused-variable]
char* input;
^~~~~
g++ -pthread -shared -B /home/shivam_gupta/anaconda3/compiler_compat -L/home/shivam_gupta/anaconda3/lib -Wl,-rpath=/home/shivam_gupta/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.7/sasl/saslwrapper.o -lsasl2 -o build/lib.linux-x86_64-3.7/sasl/saslwrapper.cpython-37m-x86_64-linux-gnu.so
unable to execute 'g++': No such file or directory
error: command 'g++' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /home/shivam_gupta/Documents/pip3-venv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vokx0cvb/sasl/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vokx0cvb/sasl/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-record-hqi5nw58/install-record.txt --single-version-externally-managed --compile --install-headers /home/shivam_gupta/Documents/pip3-venv/include/site/python3.7/sasl Check the logs for full command output.
My python version:- 3.7.6
What I do for installing hive in my ubuntu system?
And thrift-sasl also not installed.
unable to execute 'g++': No such file or directory
You don't have GNU C++ compiler. Install it:
sudo apt-get install g++
I am having issues installing a pip package on Windows 10 WSL running Debian Stretch.
While running sudo pip install invoice2data, with python3-pip installed I run into following errors.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for regex
Running setup.py clean for regex
Failed to build regex
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c regex_2/_regex.c -o build/temp.linux-x86_64-2.7/regex_2/_regex.o
regex_2/_regex.c:46:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, okenize;__file__='/tmp/pip-install-D9zG6P/regex/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-record-0dvlsB/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-D9zG6P/regex/
WSL is unrelated to the issue, this is a fairly standard error.
Ensure the following packages are installed. Install them using apt-get install packagename. The issue this particular time was resolved by installing python-dev.
python3
python3-pip
ipython3
build-essential
python-dev
python3-dev
As a single command:
sudo apt-get install python3 python3-pip ipython3 build-essential python-dev python3-dev
Had a similar error while running pip3 install pyinquirer
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-a7ojseph/regex/setup.py'"'"'; __file__='"'"'/tmp/pip-install-a7ojseph/regex/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-record-bodowot9/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.7/regex Check the logs for full command output.
Installing python3-dev didn't work for me, as I already had it installed. However installing build-essential did the trick and the regex module installed successfully.
I'm running Python 3.5 on Ubuntu. How I was able to install the regex Python package is:
$ sudo apt-get install libpython3.5-dev
$ pip3 install regex --no-use-wheel
Background research details:
I determined the package name that provides the missing Python.h file by using apt-file to locate it.
# install the apt-file package in case you don't have it
$ sudo apt-get install apt-file
# populate/refresh the local apt-file package data
$ sudo apt-file update
# search for /Python.h. Since it's a C header file,
# I also grep for /include to limit the results.
$ sudo apt-file search /Python.h | grep /include
libpython2.7-dbg: /usr/include/python2.7_d/Python.h
libpython2.7-dev: /usr/include/python2.7/Python.h
libpython3.5-dbg: /usr/include/python3.5dm/Python.h
libpython3.5-dev: /usr/include/python3.5m/Python.h
pypy-dev: /usr/lib/pypy/include/Python.h
Then made an educated guess as to which package I needed. Ignore Python2, ignore debug (dbg), ignore pypy, thus leaving libpython3.5-dev.
I landed on this page when I had a similar error on Alpine so I will leave this solution here for the alternate me when he has a similar issue :)
apk add build-base --no-cache
https://wiki.alpinelinux.org/wiki/GCC
restart the bash. I had the same error, but restarting helped
If your interpreter is pypy, then install following packages: using sudo apt-get install 'packagename'
pypy3
pypy3-pip
ipypy3
build-essential
pypy-dev
pypy3-dev
Works perfectly for installing nltk and regex
When I tried to install httrack in Ubuntu 16.04 I was not able to get those packages:
pip3 install httrack-py
Collecting httrack-py
Using cached https://files.pythonhosted.org/packages/58/b8/9499cd45ffb4efefff06090f04111c6572e7947eb4485d3333edc9505ed0/httrack-py-0.6.1.tar.gz
Installing collected packages: httrack-py
Running setup.py install for httrack-py ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-96j_4z55/httrack-py/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-f9__5p13-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 httrack.py -> build/lib.linux-x86_64-3.5
running build_ext
building 'httracklib' 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 -fdebug-prefix-map=/build/python3.5-6tVwKN/python3.5-3.5.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/home/petri/downloads/httrack-source -I/home/petri/downloads/httrack-source/src -I/usr/include -I/usr/include/python3.5 -I/usr/include/python3.5m -c src/httrack-py.c -o build/temp.linux-x86_64-3.5/src/httrack-py.o
src/httrack-py.c:45:29: fatal error: httrack-library.h: No such file or directory
#include "httrack-library.h"
^
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-96j_4z55/httrack-py/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-f9__5p13-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-96j_4z55/httrack-py/
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Run the code:
sudo apt-get update
And if its not working
Try to update repository in software centre.
The pip log says:
#include "httrack-library.h"
A necessary library header is missing.
Try running sudo apt install libhttrack-dev and then pip install again.
This question already has answers here:
Pyaudio installation error - 'command 'gcc' failed with exit status 1'
(10 answers)
Closed 4 years ago.
Pyaudio Installation failure on Ubuntu
I have ubuntu 18LTS
python 2 and python 3
pip 10
I installed libportaudio2 and libasound-dev from suggestions I found on google. Is it because I need to install other libraries as well?
Here is the error I got
I tried the sudo -H flag but no difference.
sudo python -m pip install pyaudio
The directory '/home/ec2/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ec2/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pyaudio
Downloading https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Running setup.py install for pyaudio ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-wGfA8D/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-record-IYb2Y1/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying src/pyaudio.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_portaudio' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-nbjU53/python2.7-2.7.15~rc1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o
src/_portaudiomodule.c:29:10: 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
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-wGfA8D/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-record-IYb2Y1/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-wGfA8D/pyaudio/
fatal error: portaudio.h: No such file or directory
you are missing some build dependencies, so it fails compilation. specifically, the error shows it can't find portaudio.h, which comes with the portaudio19-dev package.
so install the required headers with:
sudo apt-get install portaudio19-dev
then try your pip install.
You can try
sudo apt-get install python-pyaudio
Try this before installing the package:
sudo apt-get install portaudio19-dev
If the above suggestion doesn't work:
sudo apt-get install libjack-jackd2-dev portaudio19-dev
and pip install pyaudio should work.