Getting "cannot find -lmysqlclient" when trying to install python mysqlclient - python

I'm trying to install the mysqlclient module in a virtual environment on RHEL with Percona clustering running a Mysql db.
Each time it exits with this error
gcc -pthread -shared -Wl,-z,relro -g
build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -L/usr/lib64 -L/usr/lib64
-lmysqlclient -lpthread -lz -lm -lrt -lssl -lcrypto -ldl -lpython3.6m -o build/lib.linux-x86_64-3.6/MySQLdb/_mysql.cpython-36m-x86_64-linux-gnu.so
/bin/ld: cannot find -lmysqlclient collect2: error: ld returned 1 exit
status error: command 'gcc' failed with exit status 1
I believe I have the library installed here:
$ ls /usr/lib64/mysql/
libmysqlclient.a
libmysqlclient_r.so.18.1.0
libmysqlclient.so.18.1.0
libperconaserverclient.a
libmysqlclient_r.a
libmysqlclient.so.18
libmysqlservices.a
libperconaserverclient_r.a
So I'm not sure what the problem is

I had to explicitly pass the library path to gcc like this
sudo pip3 install mysqlclient --global-option=build_ext --global-option="-L/usr/lib64/mysql/"

Related

python ipopt install error

I am trying to install ipopt from mac terminal, but I got the following error:
terminal
/usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch
x86_64 -g build/temp.macosx-10.6-intel-3.6/src/callback.o
build/temp.macosx-10.6-intel-3.6/src/pyipoptcoremodule.o
-L/usr/local/lib -lipopt -lcoinblas -lcoinmumps -lcoinmetis -lcoinlapack -ldl -lm -o build/lib.macosx-10.6-intel-3.6/pyipopt/pyipoptcore.cpython-36m-darwin.so
ld:
library not found for -lipopt
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
error: command '/usr/bin/clang' failed with exit status 1
ipopt library is missing. Try
brew install homebrew/science/ipopt
or https://projects.coin-or.org/Ipopt/wiki/Ipopt_on_Mac_OS_X
then run pip install ipopt again.
i'm not sure if it's too late, but you can try here
git clone https://github.com/coin-or/Ipopt
make
make test
make install
that includes the missing files Ipopt/src/Interfaces/IpIpStdCInterface.h that you mentioned before

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.

install matplotlib from source using python3.5

I try to install matplotlib1.5.1 from source using python3.5 in CentOS7:
git clone https://github.com/matplotlib/matplotlib
/opt/custom_python_path/bin/python3.5 setup.py install
I get the below error:
g++ -pthread -shared -Wl,--rpath=/opt/pythonlatest/lib build/temp.linux-x86_64-3.5/src/ft2font.o build/temp.linux-x86_64-3.5/src/ft2font_wrapper.o build/temp.linux-x86_64-3.5/src/mplutils.o -L/usr/local/lib -L/usr/local/lib64 -L/usr/lib -L/usr/lib64 -L/opt/pythonlatest/lib -lfreetype -lpython3.5m -o build/lib.linux-x86_64-3.5/matplotlib/ft2font.cpython-35m-x86_64-linux-gnu.so
/usr/bin/ld: /usr/local/lib/libpython3.5m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython3.5m.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1
How else to make: setup.py install pick from /opt/custom_python_path/bin/python3.5?
The prominent error is:
recompile with -fPIC
Thanks

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

Unable to install MySQL-python under ubuntu 12.04

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.

Categories