尝试使用pip安装mysqlclient软件包时发生编译错误 [英] Compile error while try install mysqlclient package with pip

查看:109
本文介绍了尝试使用pip安装mysqlclient软件包时发生编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有安装了mariadb,python3.6和pip for python3.6的CentOS7.
我还安装了glibc-static和libstdc ++-static

I have CentOS 7 with installed mariadb, python3.6 and pip for python3.6
I also installed glibc-static and libstdc++-static

我尝试使用"pip install mysqlclient"安装mysqlclient

I try to install mysqlclient with "pip install mysqlclient"

我有此错误响应:

 building '_mysql' extension
creating build/temp.linux-x86_64-3.6
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -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 -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/include/mysql -I/usr/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o
gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-3.6/_mysql.o -L/usr/lib64 -L/usr/lib64 -lmysqlclient -lpthread -lz -lm -ldl -lssl -lcrypto -lpython3.6m -o build/lib.linux-x86_64-3.6/_mysql.cpython-36m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lz
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

如果相关的话,这里是完整输出:

And here full output if it relevant:

Collecting mysqlclient
Using cached
https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient: started
Running setup.py install for mysqlclient: finished with status 'error'
Complete output from command /usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-vajbnmgp/mysqlclient/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-wwcc1x6n/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.6
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -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 -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 -I/usr/include/mysql -I/usr/include/python3.6m -c _mysql.c -o build/temp.linux-x86_64-3.6/_mysql.o
gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-3.6/_mysql.o -L/usr/lib64 -L/usr/lib64 -lmysqlclient -lpthread -lz -lm -ldl -lssl -lcrypto -lpython3.6m -o build/lib.linux-x86_64-3.6/_mysql.cpython-36m-x86_64-linux-gnu.so
/usr/bin/ld: cannot find -lz
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

----------------------------------------

更新
我不知道mariadb在标准存储库中,因此我按照以下说明进行安装:
https://mariadb.com/kb/en/library/yum/

UPDATE
I didn't knew that mariadb is in standard repos and i installed it with this instructions:
https://mariadb.com/kb/en/library/yum/

当我从原始存储库安装它时,它可以正常工作而没有问题.

When I install it from original repos, it just works without problems.

推荐答案

是的,谢谢! "更新"是最好的解决方案,使用官方存储库重新安装mariadb解决了该问题.

Yes, Thanks ! The "update" is the best solution, reinstall of mariadb with official repository solved the problem.

rh-mariadb102-mariadb-server的问题:

The Problem with rh-mariadb102-mariadb-server :

# pip3 install mysqlclient
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: /opt/rh/rh-python36/root/usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3ts7vs5y/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-3ts7vs5y/mysqlclient/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-v5r8nc84/install-record.txt --single-version-externally-managed --compile
cwd: /tmp/pip-install-3ts7vs5y/mysqlclient/
Complete output (30 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.6/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.6/MySQLdb
creating build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.6/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/MySQLdb
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -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 -I/opt/rh/rh-python36/root/usr/include -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 -Dversion_info=(1,4,2,'post',1) -D__version__=1.4.2.post1 -I/opt/rh/rh-mariadb102/root/usr/include/mysql -I/opt/rh/rh-mariadb102/root/usr/include/mysql/mysql -I/opt/rh/rh-python36/root/usr/include/python3.6m -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o
gcc -pthread -shared -L/opt/rh/rh-python36/root/usr/lib64-Wl,-z,relro -Wl,-rpath,/opt/rh/rh-python36/root/usr/lib64 -Wl,--enable-new-dtags build/temp.linux-x86_64-3.6/MySQLdb/_mysql.o -L/opt/rh/rh-mariadb102/root/usr/lib64/mysql/ -L/opt/rh/rh-python36/root/usr/lib64 -lmariadb -lz -ldl -lm -lpthread -lssl -lcrypto -lpython3.6m -o build/lib.linux-x86_64-3.6/MySQLdb/_mysql.cpython-36m-x86_64-linux-gnu.so
/bin/ld: cannot find -lmariadb
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /opt/rh/rh-python36/root/usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-3ts7vs5y/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-3ts7vs5y/mysqlclient/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-v5r8nc84/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

在CentOS 7上删除rh-mariadb102操作

使用更新部分中的链接制作maraidb103.repo文件.

# systemctl stop rh-mariadb102-mariadb.service
# yum remove rh-mariadb102*
# vim /etc/yum.repos.d/mariadb103.repo
# yum clean all
# yum install MariaDB-server MariaDB-common mariadb-devel MariaDB-client MariaDB-shared  MariaDB-backup
# systemctl daemon-reload
# systemctl enable mariadb.service
# systemctl start mariadb.service
# systemctl status mariadb.service
# pip3 install mysqlclient
Collecting mysqlclient
  Using cached https://files.pythonhosted.org/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... done
Successfully installed mysqlclient-1.4.2.post1

这篇关于尝试使用pip安装mysqlclient软件包时发生编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆