ubuntu安装MySQL-Python出现mysql_config not found报错解决 [疑难杂症]

post by 朦朧中的罪惡 / 2010-4-22 18:49 Thursday

配置MySQL-Python的时候系统报错,提示:

EnvironmentError: mysql_config not found

Google后得知mysql_config是属于MySQL开发用的文件,而使用apt-get安装的MySQL是没有这个文件的,于是在包安装器里面寻找

libmysqld-dev

libmysqlclient-dev

这两个包安装后问题即可解决

标签: 环境配置 linux python ubuntu 疑难杂症

解决Windows下python安装MySQLdb的问题 [软件应用]

post by 朦朧中的罪惡 / 2010-4-10 22:43 Saturday

在windows下面默认安装的python2.6再安装MySQLdb会遇到很多神奇的问题,如缺少库,编译错误等

例如python2.5出现

import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python25\Lib\site-packages\MySQLdb\__init__.py", line 19, in <module>
    import _mysql
ImportError: DLL load failed: 找不到指定的程序。

解决方案:

把mysql安装目录的bin\libmySQL.dll文件复制到python安装目录的Lib\site-packages下

python2.6出现

Python 2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python26\Lib\site-packages\MySQLdb\__init__.py", line 19, in <module>     import _mysql
ImportError: DLL load failed: 找不到指定的模块。

下载libmmd.dll和libguide40.dll两个dll文件并复制到python安装目录的Lib\site- packages下

两个dll文件Google一下即可找到

还有一个

Python 2.6 (r26:66721, Oct  2 2008, 11:35:03) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
D:\usr\local\Python26\lib\site-packages\MySQLdb\__init__.py:34: DeprecationWarning: the sets module is deprecated
  from sets import ImmutableSet

解决方案:

1) 在文件 "__init__" 中将:

from sets import ImmutableSet
class DBAPISet(ImmutableSet):

替换为

class DBAPISet(frozenset)

2) 在文件 "converters.py"中移除:

from sets import BaseSet, Set

3) 在文件 "converters.py", 把 "Set" 改为 "set" (重要提示: 只有2个地方要改):

line 48: return set([ i for i in s.split(',') if i ])
line 128: set: Set2Str,

参见:

http://sourceforge.net/projects/mysql-python/forums/forum/70460/topic/2316047?message=5808948

最后再介绍一个无敌方法:

国外有个大牛直接帮我们编译好了不会出问题的MySQLdb, 去下面的网址下载安装就能解决了

http://www.codegood.com/archives/4

标签: python

Google App Engine Launcher无法启动问题解决 [疑难杂症]

post by 朦朧中的罪惡 / 2010-1-10 20:23 Sunday

今天在电脑装好了Google App Engine,在启动Google App Engine Launcher的时候它提示以下内容

点击查看原图

Error occurred

See the logfile GoolgleAppEngineLauncher.exe.log for details

打开错误日志文件GoolgleAppEngineLauncher.exe.log

发现其内容为

Traceback (most recent call last):
  File "GoogleAppEngineLauncher.py", line 42, in <module>
  File "wx\_core.pyc", line 7913, in __init__
  File "wx\_core.pyc", line 7487, in _BootstrapApp
  File "launcher\app.pyc", line 53, in OnInit
  File "launcher\app.pyc", line 97, in _CreateModels
  File "launcher\maintable.pyc", line 35, in __init__
  File "launcher\maintable.pyc", line 86, in _LoadProjects
  File "launcher\project.pyc", line 63, in ProjectWithConfigParser
  File "launcher\project.pyc", line 260, in _LoadFromConfigParser
  File "ConfigParser.pyc", line 520, in get
ConfigParser.NoOptionError: No option 'name' in section: '0'

原来是配置文件内容出了问题,然后在C:\Documents and Settings\中搜索到google_appengine_projects.ini

打开该文件,内容为

[1]
path = D:\PYTHON\engineapp
name = engineapp
port = 8080

[0]

按照记录提示所说问题是 No option 'name' in section: '0'

删除[0]保存,再次启动Google App Engine Lancher 问题解决

标签: python GoogleAppEngine

在apache上以cgi的方式运行python

post by 朦朧中的罪惡 / 2009-12-16 0:48 Wednesday

Windows下的配置方法

配置过程非常简单,打开httpd.conf

增加

ScriptAlias /python/ "D:\dev\python"

http://localhost/python/test.py的请求会引导服务器执行D:\dev\python\test.py脚本


AddHandler cgi-script .py

设置包含.py扩展名的文件,都会被当成是CGI程序

然后给你放置python脚本的目录设置属性,例如:D:\dev\python

<Directory "D:\dev\python">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
        Options ExecCGI
</Directory>

未加粗的部分可以参考Apache手册自行设置,加粗的设定该目录可以执行CGI脚本

保存,重起Apache

D:\dev\python 下面建立test.py

输入:

#!C:\Python26\python.exe
# -*- coding: utf-8 -*-
print "Content-type: text/html;charset=utf-8\n\n"
print "hello world"

访问

http://localhost/python/test.py

 

OK 你成功了!

标签: apache python