【发布时间】:2015-11-27 18:55:30
【问题描述】:
我正在构建一个需要 mysql 作为后端的 django 项目。
我创建了一个 virtualenv 并尝试使用 pip 安装 MySQL-python
pip install MySQL-python
Downloading/unpacking MySQL-python==1.2.5
Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
Running setup.py (path:/home/sayone/virtual/myvinotype/build/MySQL-python/setup.py) egg_info for package MySQL-python
sh: 1: mysql_config: not found
........
EnvironmentError: mysql_config not found
通过搜索发现需要安装libmysqlclient-dev
sudo apt-get install libmysqlclient-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libmysqlclient-dev : Depends: libmysqlclient18 (= 5.5.44-0ubuntu0.14.04.1) but 10.0.21+maria-1~trusty is to be installed
E: Unable to correct problems, you have held broken packages.
要安装MySQL-python,我们需要安装libmysqlclient-dev,但它最终与mariadb存在未满足的依赖关系(不确定)
操作系统:Ubuntu 14.04 LTS
非常感谢任何帮助。
编辑: 安装sudo apt-get install libmariadbclient-dev 后,我可以毫无问题地安装MySQL-python(我不确定这是否可以作为答案添加)。
【问题讨论】:
-
如果您使用的是 python 3.4 版本,我建议您切换回 2.7 版本。安装mysql时3.4版本有问题。
-
@MuhammadShoaib Django docs 建议使用
mysqlclient而不是MySQL-python。它适用于 Python 3.3+,因此无需降级到 2.7。 -
@MuhammadShoaib 我正在使用 python 2.7
标签: python mysql django virtualenv mysql-python