Not if that test script is simple enough that it conforms to both 2.7 and 3.x standards and will execute in either scenario.
You should be able to check the log file to see which version is being called. Like I said, are there any other log entries which may be relevant? From: "Adrya Stembridge" <[email protected]> To: [email protected] Sent: Tuesday, May 30, 2017 3:03:32 PM Subject: Re: [Trac] "ImportError: No module named trac.web.main" on fresh install with WSGI mod_wsgi tests ok with the sample "Hello World" script included in the original post. I see "Hello World" in the browser with no errors in httpd. I'm not well versed in Python, but if it works OK with a simple test script wouldn't that indicate it is installed and functioning properly (as a baseline)? On Tue, May 30, 2017 at 2:45 PM, Logan Anderson < [email protected] > wrote: Are you using mod_wsgi compiled for the wrong version of python or something of that nature? mod_wsgi has to be compiled for python 2.7. You are referencing #!/usr/bin/python2 but if the other modules are not compiled for the same version then you will run into errors such as this. Also, not certain if this is an issue for you but generally I use something more like #!/usr/bin/env python-2.7 for my shebang. This is what my demo trac.wsgi looks like. I am using virtualenv: import sys sys.stdout = sys.stderr import os activate_this = os.path.expanduser("/var/www/html/trac/bin/activate_this.py") execfile(activate_this, dict(__file__=activate_this)) os.environ['TRAC_ENV_DIR'] = '/var/www/html/trac' os.environ['PYTHON_EGG_CACHE'] = '/var/www/html/trac/logan/eggs' import trac.web.main def application(environ, start_response): environ['trac.env_path'] = '/var/www/html/trac/logan' return trac.web.main.dispatch_request(environ, start_response) From: "Adrya Stembridge" < [email protected] > To: [email protected] Sent: Tuesday, May 30, 2017 2:39:14 PM Subject: Re: [Trac] "ImportError: No module named trac.web.main" on fresh install with WSGI It is properly configured with the actual path. I did a find/replace of actual my path before posting. Never can be too careful. On Tue, May 30, 2017 at 2:33 PM, Logan Anderson < [email protected] > wrote: BQ_BEGIN You have the following: environ.setdefault('trac.env_path', '/path/to/trac') Does your wsgi file literally say '/path/to/trac' ? Or have you properly configured it for your actual path? From: "ams" < [email protected] > To: "Trac Users" < [email protected] > Sent: Tuesday, May 30, 2017 2:03:25 PM Subject: [Trac] "ImportError: No module named trac.web.main" on fresh install with WSGI Recently rebuilt a server with RHEL7. I had to reinstall trac too, but after installing I am seeing the error "ImportError: No module named trac.web.main" in the Apache HTTPD log files. Here are my install steps: ----------------------------------------- ## Install trac pip install trac ## create the wsgi script trac-admin /path/to/trac/ initenv trac-admin /path/to/trac/ deploy /tmp/deploy ## examine script cat /tmp/deploy/cgi-bin/trac.wsgi [root@nbs]# cat /path/to/trac/cgi-bin/trac.wsgi #!/usr/bin/python2 # -*- coding: utf-8 -*- # # Copyright (C)2008-2009 Edgewall Software # Copyright (C) 2008 Noah Kantrowitz < [email protected] > # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://trac.edgewall.org/wiki/TracLicense . # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://trac.edgewall.org/log/ . # # Author: Noah Kantrowitz < [email protected] > import os def application(environ, start_request): if not 'trac.env_parent_dir' in environ: environ.setdefault('trac.env_path', '/path/to/trac') if 'PYTHON_EGG_CACHE' in environ: os.environ['PYTHON_EGG_CACHE'] = environ['PYTHON_EGG_CACHE'] elif 'trac.env_path' in environ: os.environ['PYTHON_EGG_CACHE'] = \ os.path.join(environ['trac.env_path'], '.egg-cache') elif 'trac.env_parent_dir' in environ: os.environ['PYTHON_EGG_CACHE'] = \ os.path.join(environ['trac.env_parent_dir'], '.egg-cache') from trac.web.main import dispatch_request return dispatch_request(environ, start_request) ## Move trac scripts to correct location mv /tmp/deploy/* /path/to/trac/ ## Set permissions chown -R apache:apache /path/to/trac/ chmod 700 /path/to/trac/cgi-bin/trac.wsgi ## create trac.conf for Apache HTTPD WSGIScriptAlias /trac /path/to/trac/cgi-bin/trac.wsgi <Directory /path/to/trac/> WSGIApplicationGroup %{GLOBAL} # For Apache 2.2 <IfModule !mod_authz_core.c> Order deny,allow Allow from all </IfModule> # For Apache 2.4 <IfModule mod_authz_core.c> Require all granted </IfModule> </Directory> <Location "/trac/login"> AuthType Basic AuthName "Trac" AuthUserFile /data/www/htpasswd/trac.htpasswd Require valid-user </Location> ## Restart apache service httpd restart ## browser shows: Internal Server Error ## httpd error log shows: [DATE] [:error] [pid 3286] [client CLIENT_IP:55491] mod_wsgi (pid=3286): Exception occurred processing WSGI script '/path/to/trac/cgi-bin/trac.wsgi'. [DATE] [:error] [pid 3286] [client CLIENT_IP:55491] Traceback (most recent call last): [DATE] [:error] [pid 3286] [client CLIENT_IP:55491] File "/path/to/trac/cgi-bin/trac.wsgi", line 30, in application [DATE] [:error] [pid 3286] [client CLIENT_IP:55491] from trac.web.main import dispatch_request [DATE] [:error] [pid 3286] [client CLIENT_IP:55491] ImportError: No module named trac.web.main ## If I point trac.conf WSGI to a test script: def application(environ, start_response): start_response('200 OK',[('Content-type','text/html')]) return ['<html><body>Hello World!</body></html>'] I see the "Hello World" in the browser. WSGI appears to be working OK. Something is off in the trac installation but I am unsure what exactly. Help is greatly appreciated. ams -- You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] . To post to this group, send email to [email protected] . Visit this group at https://groups.google.com/group/trac-users . For more options, visit https://groups.google.com/d/optout . -- You received this message because you are subscribed to a topic in the Google Groups "Trac Users" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/trac-users/yeheTRZRjys/unsubscribe . To unsubscribe from this group and all its topics, send an email to [email protected] . To post to this group, send email to [email protected] . Visit this group at https://groups.google.com/group/trac-users . For more options, visit https://groups.google.com/d/optout . -- You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] . To post to this group, send email to [email protected] . Visit this group at https://groups.google.com/group/trac-users . For more options, visit https://groups.google.com/d/optout . -- You received this message because you are subscribed to a topic in the Google Groups "Trac Users" group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/trac-users/yeheTRZRjys/unsubscribe . To unsubscribe from this group and all its topics, send an email to [email protected] . To post to this group, send email to [email protected] . Visit this group at https://groups.google.com/group/trac-users . For more options, visit https://groups.google.com/d/optout . BQ_END -- You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] . To post to this group, send email to [email protected] . Visit this group at https://groups.google.com/group/trac-users . For more options, visit https://groups.google.com/d/optout . -- You received this message because you are subscribed to the Google Groups "Trac Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/trac-users. For more options, visit https://groups.google.com/d/optout.
