我应该使用什么软件包来查询Python中的Mysql数据库?

时间:2011-05-19 11:41:20

标签: python mysql

我需要用Python查询Mysql数据库。

我安装了虚拟env,还有PIP,我尝试安装此软件包http://pypi.python.org/pypi/MySQL-python/#downloads,但没有成功。

我已经命令了这个命令:

sudo pip install http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f

我得到了错误:

(python_virtualenv)andre@ubuntu:~/workspace/RS_r/src$ sudo pip install http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f
[sudo] password for andre: 
Downloading/unpacking http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f
  Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded
  Running setup.py egg_info for package from http://pypi.python.org/packages/source/M/MySQL-python/MySQL-python-1.2.3.tar.gz#md5=215eddb6d853f6f4be5b4afc4154292f
    sh: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/tmp/pip-l0kPkg-build/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 "/tmp/pip-l0kPkg-build/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
Storing complete log in /home/andre/.pip/pip.log

我的问题。我应该安装什么软件包来查询Mysql数据库以及我应该如何安装?在这种情况下应该使用Pip安装吗?

给我一​​个线索。

致以最诚挚的问候,

3 个答案:

答案 0 :(得分:4)

错误讯息是自言自语

sh: mysql_config: not found

mysql_config是MySQL安装的一部分,既不安装也不可用 来自$ PATH。这是要解决的问题 - 而不是关于绑定替代方案的问题。

答案 1 :(得分:1)

错误消息显示您缺少mysql_config(并且似乎在Ubuntu计算机上):

EnvironmentError: mysql_config not found
...
sh: mysql_config: not found

dpkg -S可以显示哪个包提供mysql_config - 假设您安装了mysql_config的计算机...:)

% dpkg -S $(which mysql_config)
libmysqlclient-dev: /usr/bin/mysql_config

因此,您似乎需要安装 libmysqlclient-dev 包。

PS。如果您没有安装mysql_config的计算机,则可以在http://packages.ubuntu.com/找到相同的信息。

答案 2 :(得分:0)

查看以下链接:onetwothree 您可以找到here

的来源