gpt4 book ai didi

python - Linux 上的 Django MySQLClient pip 编译失败

转载 作者:太空狗 更新时间:2023-10-29 12:02:13 24 4
gpt4 key购买 nike

自 v1.8 起的 Django 文档建议为框架使用 mysqlclient 连接器。我正在尝试使用 Python 3.4 在 Ubuntu 14.04 上 pip 安装软件包,但遇到了一个我无法找到引用的 GCC 错误。我不是编译软件方面的专家,所以希望有人能看到解决方案。

我认为我遇到了链接错误。我已经安装了发行版特定的 mysql header ,但看起来它们只适用于 Python 2.7.x。

不确定其中有多少是有用的,所以对于冗长的粘贴表示歉意,但这是错误日志:

Using version 1.3.6 (newest of versions: 1.3.6, 1.3.5, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0)
Downloading from URL https://pypi.python.org/packages/source/m/mysqlclient/mysqlclient-1.3.6.tar.gz#md5=58d7c9c617a4286a88db290e7857d3aa (from https://pypi.python.org/simple/mysqlclient/)
Running setup.py (path:/tmp/pycharm-packaging4.tmp/mysqlclient/setup.py) egg_info for package mysqlclient
running egg_info
creating pip-egg-info/mysqlclient.egg-info
writing dependency_links to pip-egg-info/mysqlclient.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/mysqlclient.egg-info/top_level.txt
writing pip-egg-info/mysqlclient.egg-info/PKG-INFO
writing manifest file 'pip-egg-info/mysqlclient.egg-info/SOURCES.txt'
warning: manifest_maker: standard file '-c' not found

reading manifest file 'pip-egg-info/mysqlclient.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pip-egg-info/mysqlclient.egg-info/SOURCES.txt'
Source in /tmp/pycharm-packaging4.tmp/mysqlclient has version 1.3.6, which satisfies requirement mysqlclient
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient
Running command /home/tim/BingVEnv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pycharm-packaging4.tmp/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-4bp9npvl-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/tim/BingVEnv/include/site/python3.4
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.4
copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.4
creating build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.4/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.4/MySQLdb
creating build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.linux-x86_64-3.4
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,6,'final',1) -D__version__=1.3.6 -I/usr/include/mysql -I/home/tim/BingVEnv/include -I/usr/include/python3.4m -c _mysql.c -o build/temp.linux-x86_64-3.4/_mysql.o -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing
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 -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/_mysql.o -lmysqlclient -lpthread -lz -lm -ldl -o build/lib.linux-x86_64-3.4/_mysql.cpython-34m.so
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Complete output from command /home/tim/BingVEnv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pycharm-packaging4.tmp/mysqlclient/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-4bp9npvl-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/tim/BingVEnv/include/site/python3.4:
running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-3.4

copying _mysql_exceptions.py -> build/lib.linux-x86_64-3.4

creating build/lib.linux-x86_64-3.4/MySQLdb

copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.4/MySQLdb

copying MySQLdb/compat.py -> build/lib.linux-x86_64-3.4/MySQLdb

copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.4/MySQLdb

copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.4/MySQLdb

copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.4/MySQLdb

copying MySQLdb/release.py -> build/lib.linux-x86_64-3.4/MySQLdb

copying MySQLdb/times.py -> build/lib.linux-x86_64-3.4/MySQLdb

creating build/lib.linux-x86_64-3.4/MySQLdb/constants

copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants

copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants

copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants

copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants

copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants

copying MySQLdb/constants/REFRESH.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants

copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.4/MySQLdb/constants

running build_ext

building '_mysql' extension

creating build/temp.linux-x86_64-3.4

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Dversion_info=(1,3,6,'final',1) -D__version__=1.3.6 -I/usr/include/mysql -I/home/tim/BingVEnv/include -I/usr/include/python3.4m -c _mysql.c -o build/temp.linux-x86_64-3.4/_mysql.o -fPIC -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing

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 -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/_mysql.o -lmysqlclient -lpthread -lz -lm -ldl -o build/lib.linux-x86_64-3.4/_mysql.cpython-34m.so

/usr/bin/ld: cannot find -lz

collect2: error: ld returned 1 exit status

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

最佳答案

看起来你缺少 zlib;你会想要安装它:apt-get install zlib1g-dev

我还建议阅读自述文件并确认您满足所有其他依赖项:https://github.com/dccmx/mysqldb/blob/master/README

此外,我建议使用 mysqlclient 而不是 MySQLdb 作为 MySQLdb 和 what Django recommends 的分支。 .

关于python - Linux 上的 Django MySQLClient pip 编译失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30989942/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com