Unable to install MySQL-python under ubuntu 12.04 - python

I'm trying to install mysql-python module in ubuntu 12.04 under virtualenv environment but unexpectedly faced with error below:
building '_mysql' extension
creating build/temp.linux-x86_64-2.7
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall
-Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/usr/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1
In file included from /usr/include/mysql/mysql.h:64:0,
from _mysql.c:46:
/usr/include/mysql/mysql/client_plugin.h:97:3: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
In file included from /usr/include/mysql/mysql.h:64:0,
from _mysql.c:46:
/usr/include/mysql/mysql/client_plugin.h:107:3: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions
-Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib/x86_64-linux-gnu
-lmysqlclient_r -lpthread -lz -lm -lrt -ldl -o build/lib.linux-x86_64-2.7/_mysql.so
/usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
I've run:
sudo apt-get install mysql-server mysql-client python-mysqldb libmysqlclient-dev python-dev
but it didn't help.

The problem was that libmysqlclient.so didn't have symlinks described in https://github.com/javer/gentoo-overlay/issues/4#issuecomment-30748799

For me on Centos, the problem was that MySQL-python did not provide the libmysqlclient_r.so but it had the other numbered versions. By uninstalling it and installing Percona-SQL-devel instead, python was able to find the library and build wheel correctly.

Related

Psycopg2-binary installation issue

While installing psycopg2 binary python package, am getting the below error
copg/typecast.c -o build/temp.linux-x86_64-3.7/psycopg/typecast.o -Wdeclaration-after-statement
gcc -pthread -shared -B /data/softwares/AnacondaPackages/anaconda3/compiler_compat -L/data/softwares/AnacondaPackages/anaconda3/lib -Wl,-rpath=/data/softwares/AnacondaPackages/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ -Wl,-O2,--sort-common,--as-needed,-z,relro,-z,now -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -pipe -D_FORTIFY_SOURCE=2 -O2 build/temp.linux-x86_64-3.7/psycopg/psycopgmodule.o build/temp.linux-x86_64-3.7/psycopg/green.o build/temp.linux-x86_64-3.7/psycopg/pqpath.o build/temp.linux-x86_64-3.7/psycopg/utils.o build/temp.linux-x86_64-3.7/psycopg/bytes_format.o build/temp.linux-x86_64-3.7/psycopg/libpq_support.o build/temp.linux-x86_64-3.7/psycopg/win32_support.o build/temp.linux-x86_64-3.7/psycopg/solaris_support.o build/temp.linux-x86_64-3.7/psycopg/connection_int.o build/temp.linux-x86_64-3.7/psycopg/connection_type.o build/temp.linux-x86_64-3.7/psycopg/cursor_int.o build/temp.linux-x86_64-3.7/psycopg/cursor_type.o build/temp.linux-x86_64-3.7/psycopg/replication_connection_type.o build/temp.linux-x86_64-3.7/psycopg/replication_cursor_type.o build/temp.linux-x86_64-3.7/psycopg/replication_message_type.o build/temp.linux-x86_64-3.7/psycopg/diagnostics_type.o build/temp.linux-x86_64-3.7/psycopg/error_type.o build/temp.linux-x86_64-3.7/psycopg/lobject_int.o build/temp.linux-x86_64-3.7/psycopg/lobject_type.o build/temp.linux-x86_64-3.7/psycopg/notify_type.o build/temp.linux-x86_64-3.7/psycopg/xid_type.o build/temp.linux-x86_64-3.7/psycopg/adapter_asis.o build/temp.linux-x86_64-3.7/psycopg/adapter_binary.o build/temp.linux-x86_64-3.7/psycopg/adapter_datetime.o build/temp.linux-x86_64-3.7/psycopg/adapter_list.o build/temp.linux-x86_64-3.7/psycopg/adapter_pboolean.o build/temp.linux-x86_64-3.7/psycopg/adapter_pdecimal.o build/temp.linux-x86_64-3.7/psycopg/adapter_pint.o build/temp.linux-x86_64-3.7/psycopg/adapter_pfloat.o build/temp.linux-x86_64-3.7/psycopg/adapter_qstring.o build/temp.linux-x86_64-3.7/psycopg/microprotocols.o build/temp.linux-x86_64-3.7/psycopg/microprotocols_proto.o build/temp.linux-x86_64-3.7/psycopg/typecast.o -L/usr/local/pgsql/lib -lpq -o build/lib.linux-x86_64-3.7/psycopg2/_psycopg.cpython-37m-x86_64-linux-gnu.so
gcc: error: unrecognized command line option ‘-fno-plt’
error: command 'gcc' failed with exit status 1
I found out it is using GCC w.r.t to OS but i want GCC of conda to be used for the installation.
pip install psycopg2-binary.tar.gz (Offline installation)

Error when installing pyminizip on docker

I am getting an error while installing pyminizip package inside docker container ( docker version 17.03.1-ce). I am doing it inside virtual environment with python 2.7.13.
I ended up with below message while trying to install it.
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Isrc -Izlib123 -I/usr/local/include/python2.7 -c src/py_minizip.c -o build/temp.linux-x86_64-2.7/src/py_minizip.o
src/py_minizip.c: In function ‘_compress’:
src/py_minizip.c:251: warning: ‘filepathnameinzip’ may be used uninitialized in this function
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Isrc -Izlib123 -I/usr/local/include/python2.7 -c src/zip.c -o build/temp.linux-x86_64-2.7/src/zip.o
In file included from src/zip.c:66:
src/crypt.h:34: error: redefinition of typedef ‘z_crc_t’
src/zip.h:83: note: previous declaration of ‘z_crc_t’ was here
src/zip.c:201: warning: function declaration isn’t a prototype
src/zip.c:203: warning: function declaration isn’t a prototype
error: command 'gcc' failed with exit status 1
Is there any alternate of pyminizip package ?
I want to create a password protected zip. So, even if there is any alternate solution to it, please let me know.
Would be useful know what docker image you use... but Try to Install python developer version:
sudo apt-get install python-dev
and libevent libraries
sudo apt-get install libevent-dev
This issue has been resolved. It is working fine with pyminizip version 0.2.1. I had faced this issue on 0.2.2 and
0.2.3 but version 0.2.1 is working fine for me.

Install mysqlclient-python in Docker

I am trying install mysqlclient-python in docker with Debian 8
but when I run python3 setup.py install
I get error:
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/_mysql.o -lmysqlclient -lpthread -lz -lm -ldl -lssl -lcrypto -o build/lib.linux-x86_64-3.4/_mysql.cpython-34m.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
I tryed install various packages (openssl, crypto++, libmysqlclient-dev, mysql-client,...) but nothing helped me..
Do you know what exactly I need?
If -lssl and -lcrypto are failing, you're likely missing the libssl headers
On debian-based systems you can install these with
apt-get install libssl-dev
Most likely you'll already have an apt line in your Dockerfile which installs libmysqlclient-dev, you'll simply add libssl-dev to the list of packages there.

error: command 'c++' failed with exit status 1

So I am trying to install Pyv8 by following instruction from https://andrewwilkinson.wordpress.com/2012/01/23/integrating-python-and-javascript-with-pyv8/
sudo aptitude install scons libboost-python-dev
svn checkout http://v8.googlecode.com/svn/trunk/ v8
svn checkout http://pyv8.googlecode.com/svn/trunk/ pyv8
cd v8
export PyV8=`pwd`
cd ../pyv8
python setup.py build
sudo python setup.py install
Error comes when running second last command about building the setup.
-Wstrict-prototypes -fPIC -DBOOST_PYTHON_STATIC_LIB -
DV8_NATIVE_REGEXP -DENABLE_DEBUGGER_SUPPORT -DV8_TARGET_ARCH_X64 -
I/home/amit/Downloads/pyv8/build/v8_r19632/include -
I/home/amit/Downloads/pyv8/build/v8_r19632 -
I/home/amit/Downloads/pyv8/build/v8_r19632/src -I/usr/local/include -
I/usr/include/python2.7 -c src/PyV8.cpp -o build/temp.linux-x86_64-
2.7/src/PyV8.o -Wno-write-strings -g -O3
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for
C/ObjC but not for C++ [enabled by default]
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/src/Utils.o build/temp.linux-x86_64-2.7/src/Exception.o
build/temp.linux-x86_64-2.7/src/Context.o build/temp.linux-x86_64-
2.7/src/Engine.o build/temp.linux-x86_64-2.7/src/Wrapper.o
build/temp.linux-x86_64-2.7/src/Debug.o build/temp.linux-x86_64-
2.7/src/Locker.o build/temp.linux-x86_64-2.7/src/AST.o build/temp.linux-
x86_64-2.7/src/PrettyPrinter.o build/temp.linux-x86_64-2.7/src/PyV8.o
L/usr/local/lib -
L/home/amit/Downloads/pyv8/build/v8_r19632/out/x64.release/obj.target/tool
s/gyp/ -lboost_python -lboost_thread -lboost_system -lrt -lv8_base.x64 -
lv8_snapshot -o build/lib.linux-x86_64-2.7/_PyV8.so -fPIC -lrt
/usr/bin/ld: cannot find -lboost_thread
/usr/bin/ld: cannot find -lboost_system
collect2: error: ld returned 1 exit status
error: command 'c++' failed with exit status 1
It is because the version of gcc and g++ is too low for me, as I downgrade it when i install cuda sometime. Just follow the following commands:
$ cd /usr/bin
$ rm gcc
$ ln -s gcc-5 gcc
$ rm g++
$ ln -s g++-5 g++
Done.
I followed the instructions from this link - http://ubuntuforums.org/showthread.php?t=1480282#post_11247864
and installed the libboost_thread package which solved the problem. Thank you https://stackoverflow.com/users/440558/joachim-pileborg

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

Categories