gpt4 book ai didi

mysql - 使用 Python 从我的机器访问单独的 MySQL 服务器 - 如何? [Mac OS X]

转载 作者:行者123 更新时间:2023-11-30 00:55:17 25 4
gpt4 key购买 nike

长话短说 - 我正在写Selenium需要访问外部服务器的webdriver Python测试MySQL数据库。我尝试使用 sudo easy_install MYSQL-python 安装 mysqldb,但收到以下消息:

EnvironmentError: mysql_config not found` (full (long) traceback below).

我对Python有点陌生,所以我不完全理解这一点,但这是否是说我需要在本地计算机上安装MySQL?如果是这样,我该怎么做,因为我不需要它,你还有其他方法可以推荐吗?另外,我运行的 Mac 为 Mac OS X Mavericks (10.9)。

Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 10, in <module>
load_entry_point('setuptools==0.6c12dev-r88846', 'console_scripts', 'easy_install')()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 1712, in main
with_ei_usage(lambda:
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 1700, in with_ei_usage
return f()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 1716, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 211, in run
self.easy_install(spec, not self.no_deps)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 446, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 476, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 655, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 930, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 919, in run_setup
run_setup(setup_script, args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/sandbox.py", line 62, in run_setup
lambda: execfile(
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/sandbox.py", line 105, in run
return func()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/sandbox.py", line 64, in <lambda>
{'__file__':setup_script, '__name__':'__main__'}
File "setup.py", line 18, in <module>
File "/tmp/easy_install-Lk4VVX/MySQL-python-1.2.4/setup_posix.py", line 43, in get_config
File "/tmp/easy_install-Lk4VVX/MySQL-python-1.2.4/setup_posix.py", line 25, in mysql_config
EnvironmentError: mysql_config not found

最佳答案

您遇到的错误消息是由于您的计算机上缺少 header 造成的。也就是说,您缺少一些库。

如果您使用 Debian基于Linux操作系统,我建议您使用aptitude提供的软件包:

sudo apt-get install python-mysqldb

顺便说一句,放弃简易安装并开始使用 pip .

sudo apt-get install python-pip

如果您只想使用 pip/another Python 安装此模块依赖管理器,您需要在计算机上安装多个工具/库才能构建它:

sudo apt-get install python-dev libmysqlclient-dev
sudo pip install MySQL-python

关于mysql - 使用 Python 从我的机器访问单独的 MySQL 服务器 - 如何? [Mac OS X],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20616647/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com