Why is pip installing textract failing on Debian? - python

I'm trying to install the python package textract on (dockerized) Debian:
FROM python:2.7
RUN apt-get update
RUN apt-get -y upgrade
RUN apt-get -y install libevent-dev python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils pstotext tesseract-ocr flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig
RUN pip install textract
But it fails on the last step pip install textract. Why? How to get around this issue? Below is the error:
Building wheels for collected packages: textract, python-pptx, docx2txt, xlrd, EbookLib, pocketsphinx
Running setup.py bdist_wheel for textract: started
Running setup.py bdist_wheel for textract: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/7b/88/ca/fe02cca616f52ba41e11ee9eff08ca0d8391f3df35e0ede5e2
Running setup.py bdist_wheel for python-pptx: started
Running setup.py bdist_wheel for python-pptx: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/14/50/ec/bf4ff7cedffcde6ef29d3154f758a5d65f40427f526cbdb1d5
Running setup.py bdist_wheel for docx2txt: started
Running setup.py bdist_wheel for docx2txt: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/a8/a1/2e/61cea06f166c6f6ac4df4d75a409328406bd0d2f8e007592f9
Running setup.py bdist_wheel for xlrd: started
Running setup.py bdist_wheel for xlrd: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/f7/2e/62/b4b26f9bc16968996a93dab7a1ec3cf9a1c8ca409114f4fefe
Running setup.py bdist_wheel for EbookLib: started
Running setup.py bdist_wheel for EbookLib: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/3a/b9/cb/834288199b3b3c6c08441d5780ce4a6cfc161d4c859f28a915
Running setup.py bdist_wheel for pocketsphinx: started
Running setup.py bdist_wheel for pocketsphinx: finished with status 'error'
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-rkBOkm/pocketsphinx/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-lmkSIP --python-tag cp27:
running bdist_wheel
running build_ext
building 'sphinxbase._ad' extension
swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
swig -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/swig
creating build/temp.linux-x86_64-2.7/swig/sphinxbase
creating build/temp.linux-x86_64-2.7/deps
creating build/temp.linux-x86_64-2.7/deps/sphinxbase
creating build/temp.linux-x86_64-2.7/deps/sphinxbase/src
creating build/temp.linux-x86_64-2.7/deps/sphinxbase/src/libsphinxad
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/local/include/python2.7 -c swig/sphinxbase/ad_wrap.c -o build/temp.linux-x86_64-2.7/swig/sphinxbase/ad_wrap.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/local/include/python2.7 -c deps/sphinxbase/src/libsphinxad/ad_pulse.c -o build/temp.linux-x86_64-2.7/deps/sphinxbase/src/libsphinxad/ad_pulse.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
deps/sphinxbase/src/libsphinxad/ad_pulse.c:44:30: fatal error: pulse/pulseaudio.h: No such file or directory
#include <pulse/pulseaudio.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for pocketsphinx
Running setup.py clean for pocketsphinx
Successfully built textract python-pptx docx2txt xlrd EbookLib
Failed to build pocketsphinx
requests 2.20.0 has requirement chardet<3.1.0,>=3.0.2, but you'll have chardet 2.3.0 which is incompatible.
Installing collected packages: argcomplete, chardet, Pillow, XlsxWriter, python-pptx, docx2txt, beautifulsoup4, xlrd, six, EbookLib, SpeechRecognition, pocketsphinx, textract
Found existing installation: chardet 3.0.4
Uninstalling chardet-3.0.4:
Successfully uninstalled chardet-3.0.4
Found existing installation: beautifulsoup4 4.6.3
Uninstalling beautifulsoup4-4.6.3:
Successfully uninstalled beautifulsoup4-4.6.3
Running setup.py install for pocketsphinx: started
Running setup.py install for pocketsphinx: finished with status 'error'
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-rkBOkm/pocketsphinx/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-MiPh8Y/install-record.txt --single-version-externally-managed --compile:
running install
running build_ext
building 'sphinxbase._ad' extension
swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
swig -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -Ideps/sphinxbase/swig -outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/swig
creating build/temp.linux-x86_64-2.7/swig/sphinxbase
creating build/temp.linux-x86_64-2.7/deps
creating build/temp.linux-x86_64-2.7/deps/sphinxbase
creating build/temp.linux-x86_64-2.7/deps/sphinxbase/src
creating build/temp.linux-x86_64-2.7/deps/sphinxbase/src/libsphinxad
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/local/include/python2.7 -c swig/sphinxbase/ad_wrap.c -o build/temp.linux-x86_64-2.7/swig/sphinxbase/ad_wrap.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DSPHINXBASE_EXPORTS -DPOCKETSPHINX_EXPORTS -DSPHINX_DLL -DHAVE_CONFIG_H -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/android -I/usr/local/include/python2.7 -c deps/sphinxbase/src/libsphinxad/ad_pulse.c -o build/temp.linux-x86_64-2.7/deps/sphinxbase/src/libsphinxad/ad_pulse.o -Wno-unused-label -Wno-strict-prototypes -Wno-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-sign-compare -Wno-misleading-indentation
deps/sphinxbase/src/libsphinxad/ad_pulse.c:44:30: fatal error: pulse/pulseaudio.h: No such file or directory
#include <pulse/pulseaudio.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-rkBOkm/pocketsphinx/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-MiPh8Y/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-rkBOkm/pocketsphinx/
ERROR: Service 'baleen' failed to build: The command '/bin/sh -c pip install textract' returned a non-zero code: 1

Solution:
Add RUN apt-get -y install libpulse-dev before pip installing textract.

It has clealy shows the error.
The chardet version-<3.1.0,>=3.0.2 is needed, but you have a older version<2.3.0>.
So you need uninstall your chardet
sudo pip list | grep chardet
then uninstall old version
sudo pip uninstall chardet

Related

Mac OS: Catalina: unable to execute 'gcc': No such file or directory

MAC OS Catalina(10.15.1) seems to have created some problems for building code that uses gcc. I am trying to build a python application which is running into the following error.
Running setup.py install for pdftotext: started
Running setup.py install for pdftotext: finished with status 'error'
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-yzaiz97e/pdftotext/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-67h0h5_9-record/install-record.txt --single-version-externally-managed --compile:
WARNING: pkg-config not found--guessing at poppler version.
If the build fails, install pkg-config and try again.
/usr/lib64/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running install
running build
running build_ext
building 'pdftotext' extension
creating build
creating build/temp.linux-x86_64-3.7
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPOPPLER_CPP_AT_LEAST_0_30_0=1 -I/usr/include/python3.7m -c pdftotext.cpp -o build/temp.linux-x86_64-3.7/pdftotext.o -Wall
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
gcc is definitely installed on the system but somehow not visible to pip installer.
which gcc
/usr/bin/gcc
packaging % gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.8)
Target: x86_64-apple-darwin19.0.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Any help to debug the issue would be appreciated.

pip install module error

hello guys i tried to install a python module called gmpy2 with pip install gmpy2 but error occurs during wheel building
running install
running build
running build_ext
building 'gmpy2' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-
prototypes -g -fdebug-prefix-map=/build/python3.6-LpWKty/python3.6-
3.6.5~rc1=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-
protector-strong -Wformat -Werror=format-security -Wdate-time -
D_FORTIFY_SOURCE=2 -fPIC -DWITHMPFR -DWITHMPC -
I/usr/include/python3.6m -c src/gmpy2.c -o build/temp.linux-x86_64-
3.6/src/gmpy2.o
In file included from src/gmpy2.c:426:0:
src/gmpy.h:252:12: fatal error: mpfr.h: No such file or directory
# include "mpfr.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-
onv0x975/gmpy2/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-izolloyr-record/install-record.txt --single-version-
externally-managed --compile" failed with error code 1 in /tmp/pip-
build-onv0x975/gmpy2/
I tried both pip and pip3
You need to download MPFR source code and compile it. See installation manual: https://gmpy2.readthedocs.io/en/latest/intro.html#installation

mujoco linux package installation error: exit status 1

I am trying to download mujoco which is a package which I require to simulate 3D systems for machine learning but every time I try to install it, I get the following error.
haroon#haroon-HP-ZBook-Studio-G3:~/Desktop/Machine Learning$ pip install mujoco-py
Collecting mujoco-py
Using cached mujoco-py-1.50.1.21.tar.gz
Requirement already satisfied: glfw>=1.4.0 in /usr/local/lib/python3.5/dist-
packages (from mujoco-py)
Requirement already satisfied: numpy>=1.11 in /usr/local/lib/python3.5/dist-
packages (from mujoco-py)
Requirement already satisfied: Cython>=0.25.2 in
/usr/local/lib/python3.5/dist-packages (from mujoco-py)
Requirement already satisfied: imageio>=2.1.2 in
/usr/local/lib/python3.5/dist-packages (from mujoco-py)
Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (from
imageio>=2.1.2->mujoco-py)
Building wheels for collected packages: mujoco-py
Running setup.py bdist_wheel for mujoco-py ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools,
tokenize;__file__='/tmp/pip-build-ku66fh_a/mujoco-
py/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/tmpr7sd9txypip-wheel- --python-tag
cp35:
running bdist_wheel
running build
Compiling /tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/cymj.pyx because it
changed.
[1/1] Cythonizing /tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/cymj.pyx
running build_ext
building 'mujoco_py.cymj' extension
creating /tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder
creating /tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5
creating /tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-
3.5/tmp
creating /tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-
3.5/tmp/pip-build-ku66fh_a
creating /tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-
3.5/tmp/pip-build-ku66fh_a/mujoco-py
creating /tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-
3.5/tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py
creating /tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-
3.5/tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/gl
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-
protector-strong -Wformat -Werror=format-security -Wdate-time -
D_FORTIFY_SOURCE=2 -fPIC -Imujoco_py -I/tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py -I/home/haroon/.mujoco/mjpro150/include -
I/usr/local/lib/python3.5/dist-packages/numpy/core/include -
I/usr/include/python3.5m -c /tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/cymj.c
-o /tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-
3.5/tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/cymj.o -fopenmp -w
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-
protector-strong -Wformat -Werror=format-security -Wdate-time -
D_FORTIFY_SOURCE=2 -fPIC -Imujoco_py -I/tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py -I/home/haroon/.mujoco/mjpro150/include -
I/usr/local/lib/python3.5/dist-packages/numpy/core/include -
I/usr/include/python3.5m -c /tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py/gl/osmesashim.c -o /tmp/pip-build-ku66fh_a/mujoco-
py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-
3.5/tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/gl/osmesashim.o -fopenmp -w
/tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/gl/osmesashim.c:1:23: fatal error:
GL/osmesa.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for mujoco-py
Running setup.py clean for mujoco-py
Failed to build mujoco-py
Installing collected packages: mujoco-py
Running setup.py install for mujoco-py ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-ku66fh_a/mujoco-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-r2plzkky-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'mujoco_py.cymj' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Imujoco_py -I/tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py -I/home/haroon/.mujoco/mjpro150/include -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -I/usr/include/python3.5m -c /tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/cymj.c -o /tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/cymj.o -fopenmp -w
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Imujoco_py -I/tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py -I/home/haroon/.mujoco/mjpro150/include -I/usr/local/lib/python3.5/dist-packages/numpy/core/include -I/usr/include/python3.5m -c /tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/gl/osmesashim.c -o /tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/generated/_pyxbld_LinuxCPUExtensionBuilder/temp.linux-x86_64-3.5/tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/gl/osmesashim.o -fopenmp -w
/tmp/pip-build-ku66fh_a/mujoco-py/mujoco_py/gl/osmesashim.c:1:23: fatal error: GL/osmesa.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-ku66fh_a/mujoco-
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-r2plzkky-record/install-
record.txt --single-version-externally-managed --compile" failed with error
code 1 in /tmp/pip-build-ku66fh_a/mujoco-py/
3
Mujoco-py has many dependencies. If you can't use the docker image, you have to install the dependencies yourself. Use sudo apt-get install to install the required libraries.
The current dockerfile lists these dependencies.
sudo apt-get install \
curl \
git \
libgl1-mesa-dev \
libgl1-mesa-glx \
libglew-dev \
libosmesa6-dev \
python3-pip \
python3-numpy \
python3-scipy \
net-tools \
unzip \
vim \
wget \
xpra \
xserver-xorg-dev
You might not need all of these, but it's probably no harm in installing everything. The error message in your question shows that GL/osmesa.h at least is required. That is probably included with one of the mesa packages in the list above.
For CentSO, I fix the problem by running the following commands:
sudo yum install mesa-libOSMesa-devel.x86_64
sudo yum install mesa-libGL-devel.x86_64
sudo yum install mesa-libGLU-devel.x86_64

How to change python gcc binding to gcc 4.8 version?

I want to install a auto-sklearn package which dependent on pyrfr.
The install command is curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt | xargs -n 1 -L 1 pip install.
My Env: ubuntu 12.04, python3.5-dev(in virtualenv) with gcc 4.8 and g++ 4.8 installed.
I install gcc and g++ by:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
Defaut gcc is set correctly:
➜ ~ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.1-2ubuntu1~12.04' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.1 (Ubuntu 4.8.1-2ubuntu1~12.04)
But I found python shell still show [GCC 4.6.3]:
➜ ~ python
Python 3.5.2 (default, Jul 17 2016, 17:38:18)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
And install pyrfr still saying(because need gcc 4.7 or above):
cc1plus: error: unrecognized command line option ‘-std=c++11’
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
More detail error log:
Collecting pyrfr
Downloading http://mirrors.aliyun.com/pypi/packages/95/90/95f77f76c2e3d44577ff2b96b0d365429797d9f83632b84d2c91d2b7a73a/pyrfr-0.2.0.tar.gz (340kB)
100% |████████████████████████████████| 348kB 4.9MB/s
Building wheels for collected packages: pyrfr
Running setup.py bdist_wheel for pyrfr ... error
Complete output from command /root/.virtualenvs/py35/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-wt1wfz_q/pyrfr/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/tmpcdvohh34pip-wheel- --python-tag cp35:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
creating build/lib.linux-x86_64-3.5/pyrfr
copying pyrfr/__init__.py -> build/lib.linux-x86_64-3.5/pyrfr
running build_ext
building 'pyrfr.regression' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/pyrfr
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I./include -I/root/.virtualenvs/py35/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -I/root/.virtualenvs/py35/include/python3.5m -c pyrfr/regression.cpp -o build/temp.linux-x86_64-3.5/pyrfr/regression.o -O2 -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
cc1plus: error: unrecognized command line option ‘-std=c++11’
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for pyrfr
Running setup.py clean for pyrfr
Failed to build pyrfr
Installing collected packages: pyrfr
Running setup.py install for pyrfr ... error
Complete output from command /root/.virtualenvs/py35/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-wt1wfz_q/pyrfr/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-qrvy2ohy-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/.virtualenvs/py35/include/site/python3.5/pyrfr:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
creating build/lib.linux-x86_64-3.5/pyrfr
copying pyrfr/__init__.py -> build/lib.linux-x86_64-3.5/pyrfr
running build_ext
building 'pyrfr.regression' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/pyrfr
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I./include -I/root/.virtualenvs/py35/lib/python3.5/site-packages/numpy/core/include -I/usr/include/python3.5m -I/root/.virtualenvs/py35/include/python3.5m -c pyrfr/regression.cpp -o build/temp.linux-x86_64-3.5/pyrfr/regression.o -O2 -std=c++11
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default]
cc1plus: error: unrecognized command line option ‘-std=c++11’
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/root/.virtualenvs/py35/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-wt1wfz_q/pyrfr/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-qrvy2ohy-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/.virtualenvs/py35/include/site/python3.5/pyrfr" failed with error code 1 in /tmp/pip-build-wt1wfz_q/pyrfr/
The key problem I think is python3.5 not link to gcc-4.8(even system default python2.7 not too), but google not help much.
Finnally I find the solution.. find that x86_64-linux-gnu-gcc is a command , though it doesn't looks like a command...
It seems python on ubuntu 12 would not use /usr/bin/x86_64-linux-gnu-gcc(link to /usr/bin/gcc-4.6) instead of /usr/bin/gcc, I totally coundn't understand why them do this ...
The sulotion is simple, just
cd /usr/bin
rm x86_64-linux-gnu-gcc
ln -sf gcc-4.8 x86_64-linux-gnu-gcc
If you want change g++ and cpp, also do
rm x86_64-linux-gnu-cpp
ln -sf cpp-4.8 x86_64-linux-gnu-cpp
rm x86_64-linux-gnu-g++
ln -sf g++-4.8 x86_64-linux-gnu-g++

How to install python cairo?

I am new to python3. I have created the virtual environment. I try to install the pycairo package using pip command. I need install python cairo. Please see the below info
pip install git+http://anongit.freedesktop.org/git/pycairo
Downloading/unpacking git+http://anongit.freedesktop.org/git/pycairo
Cloning http://anongit.freedesktop.org/git/pycairo to /tmp/pip-0c_foz-build
Running setup.py egg_info for package from git+http://anongit.freedesktop.org/git/pycairo
cairo >= 1.10.2 Successful
Installing collected packages: pycairo
Running setup.py install for pycairo
cairo >= 1.10.2 Successful
building 'cairo._cairo' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/python3.2mu -c src/cairomodule.c -o build/temp.linux-i686-3.2/src/cairomodule.o
src/cairomodule.c:22:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /home/nyros/Desktop/NewWeb/venv/bin/python3 -c "import setuptools;__file__='/tmp/pip-0c_foz-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lo0egc-record/install-record.txt --single-version-externally-managed --install-headers /home/nyros/Desktop/NewWeb/venv/include/site/python3.2:
cairo >= 1.10.2 Successful
creating py3cairo.pc
creating src/config.h
running install
running build
running build_ext
building 'cairo._cairo' extension
creating build
creating build/temp.linux-i686-3.2
creating build/temp.linux-i686-3.2/src
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/python3.2mu -c src/cairomodule.c -o build/temp.linux-i686-3.2/src/cairomodule.o
src/cairomodule.c:22:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command /home/nyros/Desktop/NewWeb/venv/bin/python3 -c "import setuptools;__file__='/tmp/pip-0c_foz-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lo0egc-record/install-record.txt --single-version-externally-managed --install-headers /home/nyros/Desktop/NewWeb/venv/include/site/python3.2 failed with error code 1 in /tmp/pip-0c_foz-build
Storing complete log in /home/nyros/.pip/pip.log
But I got the error. Please solve my problem. Thanks
I think this may solve your problem:
sudo apt-get install python3-dev
But I cannot guarantee that this will work 100% :-)

Categories