安装MySQL-python

Installing MySQL-python

在我的Ubuntu/Linux设备上安装mysql python时,我遇到了下面的问题,从下面看来问题是sh: mysql_config: not found。有人能给我建议怎么做吗?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
rmicro@ubuntu:~$ pip install MySQL-python
Downloading/unpacking MySQL-python
  Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded
  Running setup.py egg_info for package MySQL-python
    sh: mysql_config: not found
    Traceback (most recent call last):
      File"<string>", line 14, in <module>
      File"/home/rmicro/build/MySQL-python/setup.py", line 15, in <module>
        metadata, options = get_config()
      File"setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File"setup_posix.py", line 24, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    sh: mysql_config: not found

Traceback (most recent call last):
  File"<string>", line 14, in <module>
  File"/home/rmicro/build/MySQL-python/setup.py", line 15, in <module>
    metadata, options = get_config()
  File"setup_posix.py", line 43, in get_config
    libs = mysql_config("libs_r")
  File"setup_posix.py", line 24, in mysql_config
    raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found

----------------------------------------
Command python setup.py egg_info failed with error code 1


它是由使用Ubuntu advised to the distributions库。我知道installing Python mysqldb should be直向:P></

1
sudo apt-get install python-mysqldb

如果你真的想使用PIP to install,which is as before but not the suggested上述可能的路径,previously Please have a look at this的问题要回答:PIP和MySQL的安装与environmenterror失败:Python配置MySQL _ not foundP></

这里是很developer by the综合指导:http://///is-mysqldb-hard-to-install.html 2012年11 mysql-python.blogspot.noP></

在prerequisites for the to get to install / mysqld使用Python的PIP(which将给你想要的,如果你使用的是virtualenv):Run ThisP></

1
sudo apt-get install build-essential python-dev libmysqlclient-dev


You have options:波纹管2,描述的程序办理。P></

分布:glaslos suggested包装类P></

1
# sudo apt-get install python-mysqldb

你不能在这家virtualenv不使用A - packages(默认选项)但必须使用:P></

1
# virtualenv --system-site-packages myenv

建立你自己的清洁virtualenv使用MySQL和Python包。P></

第一virtualenv成立:P></

1
2
# virtualenv myvirtualenv
# source myvirtualenv/bin/activate

然后安装相关的限制:P></

1
# sudo apt-get build-dep python-mysqldb

现在你可以安装Python的MySQLP></

1
# pip install mysql-python

Ubuntu的包装说明是MySQL DB××Python Python Python包,pypi is(没有MySQL的分贝)P></


1
yum install mysql-devel

它的工作都在我身边。P></


reread the error message。它说:P></

sh: mysql_config: not found

如果你是Ubuntu的网络在线,mysql_configbelongs to包装libmysqlclient DEVP></


这为我工作都由Python 3P></安装mysqlclient PIP


python3与Python或MySQL,你将需要这些。这些图书馆使用mysql' S连接器C和Python(You need for installed as the C图书馆overcome阱),which some of the of the mysqldb图书馆的局限性。P></

1
2
3
   sudo apt-get install libmysqlclient-dev
   sudo apt-get install python-mysql.connector
   sudo apt-get install python3-mysql.connector


  • find the folder:sudo find / -name"mysql_config"(假设这是"/opt/local/lib/mysql5/bin")P></

  • 文件路径:export PATH:export PATH=/opt/local/lib/mysql5/bin:$PATHen intoP></

  • 安装一遍P></