First I will list my environment and status:
Environment:
System: Mac OS 10.6
Python: 2.6
Apache: 2.2
mod_wsgi: 3.3
mysql: 5.x
php: 3.5
trac:0.12
Status:
I can run trac as alone-server without problem.
Now I integrate trac to apache, problem come out. mod_wsgi can run normal wsgi page correctly, but cannot load mysql connection. I test it in piece of code, put "import MySQLdb" in wsgi page, it still cannot. I also can access trac through apache, but it shows me Cannot load Python bindings for MySQL
I refer to the apache log:
[Sun Mar 13 13:36:44 2011] [error] [client ::1] mod_wsgi (pid=37060): Target WSGI script /Users/alex/Library/apache2/htdocs/sql.wsgi' cannot be loaded as Python module.
[Sun Mar 13 13:36:44 2011] [error] [client ::1] mod_wsgi (pid=37060): Exception occurred processing WSGI script '/Users/alex/Library/apache2/htdocs/sql.wsgi'.
[Sun Mar 13 13:36:44 2011] [error] [client ::1] Traceback (most recent call last):
[Sun Mar 13 13:36:44 2011] [error] [client ::1] File "/Users/alex/Library/apache2/htdocs/sql.wsgi", line 2, in <module>
[Sun Mar 13 13:36:44 2011] [error] [client ::1] import MySQLdb
[Sun Mar 13 13:36:44 2011] [error] [client ::1] File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
[Sun Mar 13 13:36:44 2011] [error] [client ::1] File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
[Sun Mar 13 13:36:44 2011] [error] [client ::1] File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
[Sun Mar 13 13:36:44 2011] [error] [client ::1] ImportError: dlopen(/Users/alex/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.16.dylib
[Sun Mar 13 13:36:44 2011] [error] [client ::1] Referenced from: /Users/alex/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
[Sun Mar 13 13:36:44 2011] [error] [client ::1] Reason: image not found
[Sun Mar 13 13:36:57 2011] [error] [client ::1] mod_wsgi (pid=37061): Target WSGI script
This looks like mod_wsgi cannot find libmysqlclient.16.dylib. I encounter similar problem when I install mysqldb for python, so I add export
DYLD_LIBRARY_PATH=/Users/alex/Library/mysql-5.x/lib
SO python -c "import MySQLdb" can work, but mod_wsgi cannot work.
So I put
os.environ['DYLD_LIBRARY_PATH'] = '/Users/alex/Library/mysql-5.x/lib'
into trac.ini.
It doesn't work for trac in apache still.
So anyone has this problem before?
Thanks
Try LD_LIBRARY_PATH instead:
export LD_LIBRARY_PATH=/usr/local/mysql/lib/mysql:$LD_LIBRARY_PATH
The problem is that your Apache is running as 64 bit and you are using 32 bit version of MySQL, or Apache is running as 32 bit and you are using 64 bit version of MySQL.
Run the 'file' command on 'libmysqlclient.16.dylib' and it will tell you what architectures it is built for. See similar issues for the actual Python extension at:
http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX#Missing_Code_For_Architecture
You need to get hold of a far MySQL library binary or force Apache to run as same architecture. The linked documentation has some guidelines for what can be done.
Related
I am getting "Internal Server Error" when I try to access the django website.
I am using Django 1.8, Python 2.7.10, centos 6.5 and apache.
In apache log I am getting the following error:
mod_wsgi (pid=23866): Target WSGI script '/abc/abc/abc/wsgi.py' cannot be loaded as Python module.
[Mon May 25 14:40:47 2015] [error] [client xyz] mod_wsgi (pid=23866): Exception occurred processing WSGI script '/abc/abc/abc/wsgi.py'.
[Mon May 25 14:40:47 2015] [error] [client xyz] Traceback (most recent call last):
[Mon May 25 14:40:47 2015] [error] [client xyz] File "/abc/abc/abc/wsgi.py", line 12, in <module>
[Mon May 25 14:40:47 2015] [error] [client xyz] from django.core.wsgi import get_wsgi_application
[Mon May 25 14:40:47 2015] [error] [client xyz] File "/abc/lib/python2.7/site-packages/django/__init__.py", line 1, in <module>
[Mon May 25 14:40:47 2015] [error] [client xyz] from django.utils.version import get_version
[Mon May 25 14:40:47 2015] [error] [client xyz] File "/abc/lib/python2.7/site-packages/django/utils/version.py", line 7, in <module>
[Mon May 25 14:40:47 2015] [error] [client xyz] from django.utils.lru_cache import lru_cache
[Mon May 25 14:40:47 2015] [error] [client xyz] File "/abc/lib/python2.7/site-packages/django/utils/lru_cache.py", line 28
[Mon May 25 14:40:47 2015] [error] [client xyz] fasttypes = {int, str, frozenset, type(None)},
[Mon May 25 14:40:47 2015] [error] [client xyz] ^
[Mon May 25 14:40:47 2015] [error] [client xyz] SyntaxError: invalid syntax
Thanks
Although you say you are running Python 2.7, this error indicates that in fact you are using 2.6, as set literals were only introduced in 2.7.
The issue is that mod_wsgi is compiled against a specific Python version, which in your case is the one that comes with Centos 6.5. You will need to recompile it for 2.7, or find a version already compiled against that.
You need to start using virtualenv for your django project. Here's a nice tutorial. For a makeshift solution, you can just run django with python 2.7 by using python2.7 manage.py runserver. However, it's highly recommended to look into virtualenv. Makes life much easier.
With regards to making mod_wsgi use python 2.7, you need to recompile it. For that, just download the source and execute:
$ ./configure
$ make
$ sudo make install
They have a quick installation guide that you can access here.
I have successfully installed trac 1.0 . It is running fine when in standalone mode .
I am getting the following error after doing the integration with Apache mod_wsgi
mod_wsgi (pid=23895): Exception occurred processing WSGI script '/var/www/cgi-bin/trac_pcbb.trac.wsgi'.
[Tue Sep 30 19:40:27 2014] [error] [client 192.168.10.218] Traceback (most recent call last):
[Tue Sep 30 19:40:27 2014] [error] [client 192.168.10.218] File "/var/www/cgi-bin/trac_pcbb.trac.wsgi", line 30, in application
[Tue Sep 30 19:40:27 2014] [error] [client 192.168.10.218] from trac.web.main import dispatch_request
[Tue Sep 30 19:40:27 2014] [error] [client 192.168.10.218] ImportError: No module named trac.web.main
I am getting this in my error log file. Ive been searching for asolution but have found nothing. I am trying to deploy django with mod_wsgi.
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] ImportError: /usr/lib/python2.6/lib-dynload/_functools.so: wrong ELF class: ELFCLASS32
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] mod_wsgi (pid=20219): Target WSGI script '/home/dbs/public_html/test.wsgi' cannot be loaded as Python module.
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] mod_wsgi (pid=20219): Exception occurred processing WSGI script '/home/dbs/public_html/test.wsgi'.
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] Traceback (most recent call last):
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] File "/home/dbs/public_html/test.wsgi", line 6, in <module>
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] import django.core.handlers.wsgi
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] File "/home/dbs/sites/domain.com/django/core/handlers/wsgi.py", line 2, in <module>
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] from threading import Lock
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] File "/usr/lib/python2.6/threading.py", line 13, in <module>
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] from functools import wraps
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] File "/usr/lib/python2.6/functools.py", line 10, in <module>
[Wed Jun 13 12:15:53 2012] [error] [client 207.46.13.117] from _functools import partial, reduce
You have the wrong version of the functional module installed. Either install the correct binary version, or use the pure-python version.
I'm running into this error message while deploying django in apache2 using mod_wsgi and i cannot fix it:
tail -f /var/log/apache2/error.log
[Tue Dec 20 04:15:45 2011] [info] mod_wsgi (pid=3959): Adding '/usr/local/lib/python2.7/site-packages/' to path.
[Tue Dec 20 04:15:45 2011] [info] [client 80.226.1.7] mod_wsgi (pid=3959, process='', application='digitalchaot.de|/djangu'): Loading WSGI script '/home/webapps/digitalchaot/apache.wsgi'.
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7] mod_wsgi (pid=3959): Exception occurred processing WSGI script '/home/webapps/digitalchaot/apache.wsgi'.
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7] Traceback (most recent call last):
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7] File "/usr/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 284, in __call__
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7] start_response(status, response_headers)
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7] TypeError: expected byte string object for status, value of type str found
[Tue Dec 20 04:16:04 2011] [error] [client 80.226.1.7] File does not exist: /htdocs
[Tue Dec 20 04:20:11 2011] [error] [client 207.46.13.206] File does not exist: /htdocs
[Tue Dec 20 04:20:57 2011] [error] [client 207.46.13.206] File does not exist: /htdocs
I'm running Debian with Python 2.7.2 with Django 1.3.1 and the current mod_wsgi. I compiled python, django and wsgi myself due to previous errors. Does anybody have a hint what the error might be ?
For the Python error, it looks like your mod_wsgi is compiled against Python 3.1 and not Python 2.7. You need to ensure that mod_wsgi which is installed was compiled against Python 2.7.
The clue is that error message is complaining that status is a byte string instead of text string. This can only occur in Python 3.X with mod_wsgi.
Go through the checks in this document:
http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation
I'm trying to set up Apache with mod_wsgi to run Django on a Red Hat box but I'm getting the dreaded "Permission denied: '/home/pineg/.python-eggs'" egg cache extraction error.
I did what it said and made this the first line:
SetEnv PYTHON_EGG_CACHE /opt/tmp
in /etc/httpd/conf/httpd.conf
And restarted Apache:
>sudo /etc/init.d/httpd restart
But I'm still getting the same error (below). It's almost like Apache is ignoring my SetEnv.
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561] The following error occurred while trying to extract file(s) to the Python egg
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561] cache:
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561]
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561] [Errno 13] Permission denied: '/home/pineg/.python-eggs'
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561]
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561] The Python egg cache directory is currently set to:
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561]
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561] /home/pineg/.python-eggs
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561]
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561] Perhaps your account does not have write access to this directory? You can
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561] change the cache directory by setting the PYTHON_EGG_CACHE environment
[Fri May 06 10:08:37 2011] [error] [client 10.101.11.561] variable to point to an accessible directory.
This issue and the solution is described in mod_wsgi documentation at:
http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Access_Rights_Of_Apache_User
I now nothing about Apache-Django specifics, but in general
SetEnv PYTHON_EGG_CACHE /opt/tmp
does not set environment variable, it only add it to environ dict, which application(environ, start_response) function in index.wsgi should accept.
Oh well, instead of fooling with that, I told Python to not install it as a stupid egg:
>sudo python setup.py install --single-version-externally-managed --record=/opt/python/source/weird_egg_thing