install matplotlib from source using python3.5 - python

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

Related

Failed building wheel for trm.pgplot

I am working on Ubuntu 18.04 and Python 3.6 and getting the following error while installing the package:
I am trying normal pip installation:
pip3 install . --user
and getting the following error message:
Processing /home/chinmay/trm-pgplot
Building wheels for collected packages: trm.pgplot
Running setup.py bdist_wheel for trm.pgplot ... error
Complete output from command /usr/bin/python3 -u -c "import setuptools,
tokenize;file='/tmp/pip-b_8sag87-build/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/tmp6x5jsk6hpip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
package init file 'trm/init.py' not found (or not a regular file)
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/trm
creating build/lib.linux-x86_64-3.6/trm/pgplot
copying trm/pgplot/init.py -> build/lib.linux-x86_64-3.6/trm/pgplot
running build_ext
building 'trm.pgplot._pgplot' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/trm
creating build/temp.linux-x86_64-3.6/trm/pgplot
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 -DMAJOR_VERSION=0 -DMINOR_VERSION=1 -I/home/chinmay/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/local/pgplot/ -I/usr/include/python3.6m -c trm/pgplot/_pgplot.c -o build/temp.linux-x86_64-3.6/trm/pgplot/_pgplot.o
In file included from /home/chinmay/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1822:0,
from /home/chinmay/.local/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
from /home/chinmay/.local/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
from trm/pgplot/_pgplot.c:791:
/home/chinmay/.local/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2:
warning: #warning "Using deprecated NumPy API, disable it with "
"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
#warning "Using deprecated NumPy API, disable it with "
^~~~~~~
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.6/trm/pgplot/_pgplot.o -L/usr/X11R6/lib
-L/opt/local/lib -L/usr/local/pgplot/ -lcpgplot -lpgplot -lX11 -lm -lgfortran -lpng -lz -o build/lib.linux-x86_64-3.6/trm/pgplot/_pgplot.cpython-36m-x86_64-linux-gnu.so
/usr/bin/ld: /usr/local/pgplot//libpgplot.a(xwdriv.o): relocation R_X86_64_PC32 against symbol `stderr##GLIBC_2.2.5' can not
be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
try this: apt-get install libjpeg-dev zlib1g-dev
then try this: pip3 install Pillow (it worked for me)
also try updating the setup tools by: sudo pip install -U setuptools
You need c++ compiler
sudo apt install g++

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

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/"

Unable to install blist using pip

I'm trying to install blist using pip:
pip install blist
but I'm getting the following error:
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Qunused-arguments -Qunused-arguments -fPIC -DBLIST_FLOAT_RADIX_SORT=1 -I/usr/include/python2.7 -c blist/_blist.c -o build/temp.linux-x86_64-2.7/blist/_blist.o
x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-Qunused-arguments’; did you mean ‘-Wunused-parameter’?
x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-Qunused-arguments’; did you mean ‘-Wunused-parameter’?
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for blist
Running setup.py clean for blist
Failed to build blist
I tried to install python-dev and setuptools, nothing changed
I tried to export flags:
export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments
with no success.
I'm using python 2.7, ubuntu 18.04

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 'x86_64-linux-gnu-gcc' failed with exit status 4

I am new to python and don't know much about linux commands. So please, consider my problem. I have tried to run the command:
python pyglpk_setup.py build
but I got following results:
running build
running build_ext
building 'glpk' extension
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -Isrc -I/usr/include/python2.7 -c src/glpk.c -o build/temp.linux-x86_64-2.7/src/glpk.o -m64
x86_64-linux-gnu-gcc: error: src/glpk.c: No such file or directory
x86_64-linux-gnu-gcc: fatal error: no input files
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 4
I think I have installed dependencies and tried other stuffs to make it run but I am not able to resolve it.
Why do I get this error?
Seems you have a corrupt glpk :
error: src/glpk.c: No such file or directory
Please get a new "glpk-0.3.tar.gz" https://pypi.python.org/packages/dc/6c/33e383f6613a90865bddeb1666c2b6121563b21a41d12d75bc2836a6bfdb/glpk-0.3.tar.gz
$ tar xvf glpk-0.3.tar.gz
$ cd glpk-0.3/
$ python setup.py build
→ → No errors here.

Categories