I solved the problem. It is strange but in sql.py before "self._pool_connection(lambda :MySQLdb.Connection" I add import MySQLdb. I print some logs from sql.py and the first import in sql.py is not processed when running with apache. I am not sure why first import is not processed but I solved my problem with adding
"import MySQLdb" before MySQLdb.Connection is processed. self._pool_connection(lambda : MySQLdb.Connection( db=db, user=user, passwd=passwd, host=host, port=int(port), charset=charset, )) self._cursor = self._connection.cursor() self._execute = lambda *a, **b: self._cursor.execute(*a, **b) self._execute('SET FOREIGN_KEY_CHECKS=1;') self._execute("SET sql_mode='NO_BACKSLASH_ESCAPES';") On 24 Temmuz, 22:58, oktay <onur.ok...@gmail.com> wrote: > I will be very glad if you can... > Thank you. > > On 24 Temmuz, 22:51, Kenneth <kenneth.t.lundst...@gmail.com> wrote: > > > I´m running web2py on CentOS 5.something. If needed I could send you > > my Apache configuration files and others. > > > Kenneth > > > On Jul 24, 8:47 pm, oktay <onur.ok...@gmail.com> wrote: > > > > Hello again, > > > > I installed PostgreSQL and psycopg2. > > > both in the command line for python24 and python26 can import > > > psycopg2. > > > > But when I run from apache > > > "global name 'psycopg2' is not defined" > > > error appears. > > > > Same problem with mysql driver. > > > > apache/python can not find the python db drivers. > > > Is it related to wsgi configuration? > > > > Do you have any advice? Where should I check? > > > > Thank you... > > > > On 24 Temmuz, 19:38, oktay <onur.ok...@gmail.com> wrote: > > > > > Yes, correct. > > > > web2y.py (including "import MySQLdb") works both with python2.4 and > > > > python2.6. > > > > and not working with apache. > > > > > Also I make my wsgi configuration as described > > > > inhttp://web2py.com/book/default/section/11/2 > > > > > On 24 Temmuz, 19:32, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > So it works when you do > > > > > > python2.6 web2y.py > > > > > > but not when you use apache. is that correct? > > > > > > On Jul 24, 10:58 am, oktay <onur.ok...@gmail.com> wrote: > > > > > > > Yes, it works with "import MySQLdb" at the top of web2py.py: > > > > > > > web2py Enterprise Web Framework > > > > > > Created by Massimo Di Pierro, Copyright 2007-2010 > > > > > > Version 1.81.5 (2010-07-22 23:56:21) > > > > > > Database drivers available: MySQL > > > > > > Starting hardcron... > > > > > > WARNING:root:GUI not available because Tk library is not installed > > > > > > > On 24 Temmuz, 18:52, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > > As a test, can you try add > > > > > > > > import MySQLdb > > > > > > > > at the top of web2py.py and run > > > > > > > > python2.6 web2py.py > > > > > > > > Massimo > > > > > > > > On Jul 24, 10:46 am, oktay <onur.ok...@gmail.com> wrote: > > > > > > > > > Hello, > > > > > > > > > I am trying to install web2py with apache & mysql. > > > > > > > > I checked all the scenarios with the "global name 'MySQLdb' is > > > > > > > > not > > > > > > > > defined" subject, but they didn't solve my problem. > > > > > > > > > I am using: > > > > > > > > CentOS 5.5 > > > > > > > > httpd-2.2.3 > > > > > > > > mysql 5.0.77 > > > > > > > > Python26 > > > > > > > > MySQL-python-1.2.3c1 > > > > > > > > web2py Version 1.81.5 > > > > > > > > > Default CentOS 5 python version is 2.4, I installed 2.6. > > > > > > > > I can both "import MySQLdb" from python24 & python26 from > > > > > > > > console. > > > > > > > > When I run web2py from source like "python ./web2py.py" or with > > > > > > > > "python26 ./web2py.py" > > > > > > > > I can see "Database drivers available: MySQL" > > > > > > > > > I think there is a configuration problem with the python > > > > > > > > libraries I > > > > > > > > installed. > > > > > > > > > Do you have any idea? Here is the trace: > > > > > > > > > --------------- > > > > > > > > Traceback (most recent call last): > > > > > > > > File "gluon/restricted.py", line 178, in restricted > > > > > > > > exec ccode in environment > > > > > > > > File "/var/www/web2py/applications/welcome/models/db.py", > > > > > > > > line 1, in > > > > > > > > <module> > > > > > > > > db=SQLDB('mysql://xxx:y...@zzz:3306/aaa') > > > > > > > > File "gluon/sql.py", line 921, in __init__ > > > > > > > > self._pool_connection(lambda : MySQLdb.Connection( > > > > > > > > File "gluon/sql.py", line 828, in _pool_connection > > > > > > > > self._connection = f() > > > > > > > > File "gluon/sql.py", line 921, in <lambda> > > > > > > > > self._pool_connection(lambda : MySQLdb.Connection( > > > > > > > > NameError: global name 'MySQLdb' is not defined > > > > > > > > ----------------