关于python:Python3 – Pipenv安装mysqlclient?

Python3 - Pipenv install mysqlclient?

正在尝试从pipenv安装:

1
pipenv install mysqlclient

将在以下位置重置:

Installing mysqlclient… Collecting mysqlclient Using cached
https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File"", line 1, in
File"/tmp/pip-install-5vhtqgve/mysqlclient/setup.py", line 17, in
metadata, options = get_config()
File"/tmp/pip-install-5vhtqgve/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File"/tmp/pip-install-5vhtqgve/mysqlclient/setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found

1
----------------------------------------

Error: An error occurred while installing mysqlclient! Command
"python setup.py egg_info" failed with error code 1 in
/tmp/pip-install-5vhtqgve/mysqlclient/

This is likely caused by a bug in mysqlclient. Report this to its
maintainers.

我用的是Debian,用另一个virtualenv,它会得到系统包。

1
python-mysqldb/testing,now 1.3.10-1 amd64

Pipenv不会使用这个,也不会安装另一个。我怎么解决这个问题?谢谢,BR


您可能需要操作系统的mysql客户机lib。

1
sudo apt install libmysqlclient-dev

那么你应该能够:

1
pipenv install mysqlclient


我用以下命令解决了这个问题:

1
brew install mysql


首先安装python dev

sudo apt get安装python3 dev

然后安装mysqlclient dev版本

sudo apt get安装python3 dev libmysqlclient dev


如果你在Centos

试一试:yum install mariadb-devel

这个包裹包括丢失的mysql-config


我建议您先安装文件。在我使用的窗口上pip安装"mysqlclient-1.3.13-cp35-cp35m-win_amd64.whl"尝试过:pip安装mysqlclient。它工作得很好。