Errors while compiling Python with SSL support - python

I'm trying to compile Python 2.7.3 on Centos6. Almost everything works ok, except the thing I really need ^^.
When I type make, I'm getting the error:
building '_ssl' extension
gcc -pthread -fPIC -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I/usr/local/include -I/root/Python-2.7.3/Include -I/root/Python-2.7.3 -c /root/Python-2.7.3/Modules/_ssl.c -o build/temp.linux-i686-2.7/root/Python-2.7.3/Modules/_ssl.o
gcc -pthread -shared build/temp.linux-i686-2.7/root/Python-2.7.3/Modules/_ssl.o -L/usr/local/lib -lssl -lcrypto -o build/lib.linux-i686-2.7/_ssl.so
*** WARNING: renaming "_ssl" since importing it failed: build/lib.linux-i686-2.7/_ssl.so: undefined symbol: krb5_auth_con_getrcache
And at the end I'm getting a message that the build failed for module _ssl (something like this).
Have you ever faced this problem? I have installed both OpenSSL (0.9.8e fips) and OpenSSL-dev.

Make sure the right paths to openssl-dev (lib and include) are in your Makefile

Related

Why an unknown gcc is required to compile spaCy?

When installing spaCy under Ubuntu, but I got the following compile error.
The installation code is simply using pip install spacy.
/opt/rh/devtoolset-2/root/usr/bin/gcc -pthread -fPIC -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/mnt/nfs/lijin/local/opt/include/python2.7 -I/tmp/pip-install-ikyFEg/spacy/include -I/mnt/nfs/lijin/local/opt/include/python2.7 -c spacy/parts_of_speech.cpp -o build/temp.linux-x86_64-2.7/spacy/parts_of_speech.o -O2 -Wno-strict-prototypes -Wno-unused-function
unable to execute '/opt/rh/devtoolset-2/root/usr/bin/gcc': No such file or directory
error: command '/opt/rh/devtoolset-2/root/usr/bin/gcc' failed with exit status 1
My system has a /usr/bin/gcc but not in /opt/rh/xxx. Can anyone help fix this problem? Thank you.

Compiling Python 3.4/5 fails with segmentation fault on RedHat 6.4

I try to compile a new Python 3.x version on a Redhat 6.4 machine. In this example i use 3.5.1.
GCC is gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC).
./configure --prefix=/data/tools/python3
works fine, but make fails:
make
gcc -pthread -fPIC -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Werror=declaration-after-statement -Ibuild/temp.linux-x86_64-3.5/libffi/include -Ibuild/temp.linux-x86_64-3.5/libffi -I/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/libffi/src -I./Include -I. -IInclude -I/usr/local/include -I/cs/san_development/download/py3/Python-3.5.1/Include -I/cs/san_development/download/py3/Python-3.5.1 -c /cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/libffi/src/x86/sysv.S -o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/libffi/src/x86/sysv.o -Wall -fexceptions
gcc -pthread -shared build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/_ctypes.o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/callbacks.o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/callproc.o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/stgdict.o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/cfield.o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/libffi/src/prep_cif.o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/libffi/src/closures.o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/libffi/src/x86/ffi64.o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/libffi/src/x86/unix64.o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/libffi/src/x86/ffi.o build/temp.linux-x86_64-3.5/cs/san_development/download/py3/Python-3.5.1/Modules/_ctypes/libffi/src/x86/sysv.o -L/data/tools/python3/lib -L/usr/local/lib -o build/lib.linux-x86_64-3.5/_ctypes.cpython-35m-x86_64-linux-gnu.so
/bin/sh: line 6: 4791 Segmentation fault CC='gcc -pthread' LDSHARED='gcc -pthread -shared ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes' _TCLTK_INCLUDES='' _TCLTK_LIBS='' ./python -E ./setup.py $quiet build
make: *** [sharedmods] Error 139
A single execution of the last command shows:
CC='gcc -pthread' LDSHARED='gcc -pthread -shared ' OPT='-DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes' _TCLTK_INCLUDES='' _TCLTK_LIBS='' ./python -E ./setup.py $quiet build
running build
running build_ext
Segmentation fault
When I remove the $quiet and add -v to python I get:
.....
import '_csv' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc89dbfe8d0>
# extension module '_posixsubprocess' loaded from 'build/lib.linux-x86_64-3.5/_posixsubprocess.cpython-35m-x86_64-linux-gnu.so'
# extension module '_posixsubprocess' executed from 'build/lib.linux-x86_64-3.5/_posixsubprocess.cpython-35m-x86_64-linux-gnu.so'
import '_posixsubprocess' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc89dbfe978>
# extension module '_socket' loaded from 'build/lib.linux-x86_64-3.5/_socket.cpython-35m-x86_64-linux-gnu.so'
# extension module '_socket' executed from 'build/lib.linux-x86_64-3.5/_socket.cpython-35m-x86_64-linux-gnu.so'
import '_socket' # <_frozen_importlib_external.ExtensionFileLoader object at 0x7fc89dbfec50>
Segmentation fault
But that doesn't really tell my anything :-)
I think I have all the dependencies installed
I also changed -O3 to -O2 -Os or even -O0 but nothing helped.
Any help would be appreciated.
Daniel
BTW, is my first post on stackoverflow, hope I didn't make to much mistakes...
I suggest using the RH Software Collection version: http://developers.redhat.com/products/softwarecollections/get-started-rhel6-python/
This doc is for 3.4, but there's a 3.5 version too.

Python not installing sklearn

I am working with ubuntu 14. I have downloaded the dpkg package for sklearn and unpacked it. i try to run sudo python setup.py installBut it seems to be stuck in a loop
compiling C++ sources
C compiler: c++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC
creating build/temp.linux-x86_64-2.7/sklearn/utils/src
compile options: '-Isklearn/utils/src -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
c++: sklearn/utils/src/MurmurHash3.cpp
c++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/sklearn/utils/murmurhash.o build/temp.linux-x86_64-2.7/sklearn/utils/src/MurmurHash3.o -Lbuild/temp.linux-x86_64-2.7 -o build/lib.linux-x86_64-2.7/sklearn/utils/murmurhash.so
building 'sklearn.utils.lgamma' extension
compiling C sources
C compiler: x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC
compile options: '-Isklearn/utils/src -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
x86_64-linux-gnu-gcc: sklearn/utils/lgamma.c
x86_64-linux-gnu-gcc: sklearn/utils/src/gamma.c
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/sklearn/utils/lgamma.o build/temp.linux-x86_64-2.7/sklearn/utils/src/gamma.o -Lbuild/temp.linux-x86_64-2.7 -lm -o build/lib.linux-x86_64-2.7/sklearn/utils/lgamma.so
building 'sklearn.utils.graph_shortest_path' extension
compiling C sources
C compiler: x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC
compile options: '-I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
x86_64-linux-gnu-gcc: sklearn/utils/graph_shortest_path.c
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1761:0,
from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:17,
from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
from sklearn/utils/graph_shortest_path.c:256:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by " \
^
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ufuncobject.h:327:0,
from sklearn/utils/graph_shortest_path.c:257:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/__ufunc_api.h:241:1: warning: ‘_import_umath’ defined but not used [-Wunused-function]
_import_umath(void)
^
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/sklearn/utils/graph_shortest_path.o -Lbuild/temp.linux-x86_64-2.7 -o build/lib.linux-x86_64-2.7/sklearn/utils/graph_shortest_path.so
building 'sklearn.utils.fast_dict' extension
compiling C++ sources
C compiler: c++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC
compile options: '-I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c'
c++: sklearn/utils/fast_dict.cpp
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarraytypes.h:1761:0,
from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ndarrayobject.h:17,
from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/arrayobject.h:4,
from sklearn/utils/fast_dict.cpp:320:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it by " \
^
sklearn/utils/fast_dict.cpp: In function ‘PyObject* __pyx_pw_7sklearn_5utils_9fast_dict_1argmin(PyObject*, PyObject*)’:
sklearn/utils/fast_dict.cpp:18786:44: warning: ‘__pyx_v_min_key’ may be used uninitialized in this function [-Wmaybe-uninitialized]
return PyInt_FromLong((long)val);
^
sklearn/utils/fast_dict.cpp:3316:46: note: ‘__pyx_v_min_key’ was declared here
__pyx_t_7sklearn_5utils_9fast_dict_ITYPE_t __pyx_v_min_key;
^
In file included from /usr/lib/python2.7/dist-packages/numpy/core/include/numpy/ufuncobject.h:327:0,
from sklearn/utils/fast_dict.cpp:321:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/__ufunc_api.h: At global scope:
/usr/lib/python2.7/dist-packages/numpy/core/include/numpy/__ufunc_api.h:241:1: warning: ‘int _import_umath()’ defined but not used [-Wunused-function]
_import_umath(void)
^
.. and continues on like that.
I have installed numpy, but I did it through ubuntu's software center. When I try to import sklearn within python I get
from sklearn.ensemble import RandomForestClassifier Traceback (most
recent call last): File "", line 1, in File
"sklearn/init.py", line 37, in
from . import check_build File "sklearn/__check_build/__init.py", line 46, in
raise_build_error(e) File "sklearn/check_build/__init.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg)) ImportError: No module named _check_build
_______________________________________________________________________ Contents of sklearn/check_build: setup.py
__init.py _check_build.pyx
_check_build.c setup.pyc init.pyc
_______________________________________________________________________ It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run python setup.py install or
make in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
I have no idea where sklearn/check_build is located.
My folder in /usr/lib/python2.7/dist-packages is empty, but I can import numpy within python. Like I said, I used the ubuntu software center to install numpy, but not for sklearn which I regret doing now.
I recommend installing sklearn and all dependencies with Anaconda package: https://www.continuum.io/downloads#_unix
It will be installed together with numpy and other packages, full list is available here: http://docs.continuum.io/anaconda/pkg-docs
If you want your package manager to handle everything, that usually works although you won't necessarily be on the most recent version
Otherwise do something along the lines of
sudo apt-get install build-essential gcc g++ python-dev python3-dev python-scipy python3-scipy
and try to install/compile again. compiling python extension modules relies on having a working compilation environment, plus the extended or development headers for python. I'm not sure if those dependencies are 100% exactly right for Ubuntu b/c I've been using more openSUSE lately, but apt-cache search will turn you up the correct naming if I've made a typo
One of new ways to handle issues due to environment is to handle it using docker images. This allows any developer to recreate the environment in any server within a single minute. You can pull the image from here.
This can also be performed very easily using the datmo CLI tool. We faced these problems ourselves and decided to build it.
Edit: You could install as follows,
apt-get update; \
apt-get install -y python python-pip \
python-numpy \
python-scipy \
build-essential \
python-dev \
python-setuptools \
libatlas-dev \
libatlas3gf-base
update-alternatives --set libblas.so.3 /usr/lib/atlas-base/atlas/libblas.so.3; update-alternatives --set liblapack.so.3 /usr/lib/atlas-base/atlas/liblapack.so.3
pip install -U scikit-learn
Disclaimer: I work at Datmo

Intel Galileo - greenlet.h:8:20: fatal error: Python.h: No such file or directory

I'm running Linux dev-tools image (link at the end) on my intel galileo. I tried to install greenlet but I got an error stating python.h no such file.
root#clanton:/media/realroot/greenlet-0.4.2# python setup.py install
running install
running build
running build_ext
creating /tmp/tmpuKbWhk/tmp
creating /tmp/tmpuKbWhk/tmp/tmpuKbWhk
i586-poky-linux-uclibc-gcc -m32 -march=i586 -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -fno-tree-dominator-opts -I/usr/include/python2.7 -c /tmp/tmpuKbWhk/simple.c -o /tmp/tmpuKbWhk/tmp/tmpuKbWhk/simple.o
/tmp/tmpuKbWhk/simple.c:1:6: warning: function declaration isn't a prototype [-Wstrict-prototypes]
building 'greenlet' extension
creating build
creating build/temp.linux-i586-2.7
i586-poky-linux-uclibc-gcc -m32 -march=i586 -fno-strict-aliasing -O2 -pipe -g -feliminate-unused-debug-types -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -fno-tree-dominator-opts -I/usr/include/python2.7 -c greenlet.c -o build/temp.linux-i586-2.7/greenlet.o
In file included from greenlet.c:5:0:
greenlet.h:8:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'i586-poky-linux-uclibc-gcc' failed with exit status 1**
I know there are many posts with the same python.h error but my problem is the Linux image I have can't run sudo or apt commands
I need to setup python-dev environment onto my Linux image running on Galileo board.
Link to the Linux dev-tools image I'm using is here below.
http://telekinect.media.mit.edu/galileo/image-devtools-1.0.1-2.tar.bz2
p.s. it has gcc and python2.7 already.

How to set CFLAGS and LDFLAGS to compile pycrypto

I am trying to install the fabric library to an old machine. There are some legacy libraries in /usr/lib, such as libgmp.
(py27)[qrtt1#hcservice app]$ ls /usr/lib|grep gmp
libgmp.a
libgmp.so
libgmp.so.3
libgmp.so.3.3.3
libgmpxx.a
libgmpxx.so
libgmpxx.so.3
libgmpxx.so.3.0.5
I have compiled the libgmp 5.x in my $HOME/app, and then am trying to install pycrypto (it is the dependency of fab):
CFLGAS=-I/home/qrtt1/app/include LDFLGAS=-L/home/qrtt1/app/lib pip install pycrypto
I observed that none of my include or lib directories are in the in the compilation / linking options:
gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/usr/include/ -I/home/qrtt1/app/include/python2.7 -c src/_fastmath.c -o build/temp.linux-i686-2.7/src/_fastmath.o
gcc -pthread -shared build/temp.linux-i686-2.7/src/_fastmath.o -lgmp -o build/lib.linux-i686-2.7/Crypto/PublicKey/_fastmath.so
building 'Crypto.Hash._MD2' extension
gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/home/qrtt1/app/include/python2.7 -c src/MD2.c -o build/temp.linux-i686-2.7/src/MD2.o
gcc -pthread -shared build/temp.linux-i686-2.7/src/MD2.o -o build/lib.linux-i686-2.7/Crypto/Hash/_MD2.so
building 'Crypto.Hash._MD4' extension
gcc -pthread -fno-strict-aliasing -fwrapv -Wall -Wstrict-prototypes -fPIC -std=c99 -O3 -fomit-frame-pointer -Isrc/ -I/home/qrtt1/app/include/python2.7 -c src/MD4.c -o build/temp.linux-i686-2.7/src/MD4.o
gcc -pthread -shared build/temp.linux-i686-2.7/src/MD4.o -o build/lib.linux-i686-2.
How do I assign the CFLAGS and LDFLAGS correctly for building pycrypto ?
I try to download pycrypto-2.5 and install it:
(py27)[qrtt1#hcservice pycrypto-2.5]$ CFLGAS=-I/home/qrtt1/app/include LDFLGAS=-L/home/qrtt1/app/lib python setup.py install
No CFLAGS or LDFLAGS set up with it. May be the pycrypto-2.5 going wrong ?
Please check what you have typed :
CFLAGS=-I/home/qrtt1/app/include LDFLAGS=-L/home/qrtt1/app/lib pip install pycrypto
it should be CFLAGS

Categories