我正在構建一個需要mysql作爲後端的django項目。沒有在virtualenv中安裝MySQL-python(EnvironmentError:找不到mysql_config)
我創建了一個的virtualenv並嘗試使用PIP
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
安裝MySQL-python的通過搜索我發現我需要安裝的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(不確定)
Os:Ubuntu 14.04 LTS
任何幫助,非常感謝。
編輯:安裝sudo apt-get install libmariadbclient-dev
之後我能夠安裝MySQL-python
沒有任何問題(我不知道這是可以添加爲答案)。
如果您使用的是Python 3.4版,我會建議您切換回2.7版。安裝mysql時,版本3.4中存在問題。 –
@MuhammadShoaib [Django文檔](https://docs.djangoproject.com/en/1.8/ref/databases/#mysql-db-api-drivers)推薦使用'mysqlclient'而不是'MySQL-python'。它適用於Python 3.3+,所以不需要降級到2.7。 – Alasdair
@MuhammadShoaib我使用Python 2.7 –