gpt4 book ai didi

Python AppEngine 'import MySQLdb' 不工作,OS X 10.9.2,python 2.7

转载 作者:行者123 更新时间:2023-11-29 04:43:23 24 4
gpt4 key购买 nike

我已经为我的系统 python 成功安装了 MySQLdb——我也已经将该库添加到 app.yaml,但是 dev-appserver 无法识别它。我已经按照这里的教程进行操作:https://developers.google.com/appengine/docs/python/cloud-sql/

我从这里下载并安装了最新的 Python mysql: http://sourceforge.net/projects/mysql-python/

sudo CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments python setup.py build
sudo CFLAGS=-Qunused-arguments CPPFLAGS=-Qunused-arguments python setup.py install

如果我从命令行运行 python,我可以愉快地导入 MySQLdb

这是我在 app.yaml 中的内容:

libraries:
- name: webapp2
version: "2.5.2"
- name: jinja2
version: "2.6"
- name: MySQLdb
version: "1.2.4b4"

这是我尝试打开由我的应用引擎开发服务器托管的页面时遇到的异常。

ERROR    2014-05-15 20:23:19,480 wsgi.py:262] 
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 298, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 84, in LoadObject
obj = __import__(path[0])
File "xxxx/main.py", line 10, in <module>
import MySQLdb
ImportError: No module named MySQLdb

我们将不胜感激任何帮助——该教程无法正常工作。感谢您的慷慨和善意!

-s

最佳答案

以下对我有用。我从 App Engine 得到了同样的错误,但事实证明问题是模块 _mysql 配置不正确。

将此添加到 ~/.bash_profile:

export PATH=$PATH:/usr/local/mysql/bin

创建一个指向 MySQL 库的符号链接(symbolic link):

ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

关于Python AppEngine 'import MySQLdb' 不工作,OS X 10.9.2,python 2.7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23688008/

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