Pip cài đặt lỗi mysqlclient linux

Làm việc với tư cách là nhà phát triển Django hoặc Flask, bạn có thể cần cài đặt MySQL và MySQLClient. Trong khi cài đặt MySQLClient, bạn có thể thấy lỗi này MySQLClient pip compile failure on Linux

Lỗi cài đặt pip Python MySQLClient

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

Giải quyết lỗi biên dịch pip MySQLClient trên Linux

Lỗi này có thể bật lên do thiếu phụ thuộc và thư viện. Thực hiện theo các bước này trước khi pip install mysqlclient

Tại sao mysqlclient không cài đặt?

Trước tiên, hãy kiểm tra xem bạn đã kết nối với Internet chưa và kết nối có ổn định không . Hãy thử chạy lại lệnh. Tiếp theo, bạn sẽ phải tải xuống và cài đặt gói thủ công nếu sự cố vẫn tiếp diễn. Để làm điều này, bạn có thể Google tệp nhị phân của mysqlclient tương thích với thiết bị của bạn hoặc bạn có thể truy cập trang web này.

mysqlclient cho Python là gì?

mysqlclient là một nhánh của MySQL-python. Nó thêm Python 3. 3 hỗ trợ và hợp nhất một số yêu cầu kéo. MySQLdb là một giao diện cho máy chủ cơ sở dữ liệu MySQL phổ biến dành cho Python. Mục tiêu thiết kế là. Tuân thủ API cơ sở dữ liệu Python phiên bản 2. 0 [PEP-0249]