I'm using Apache + mod-wsgi.
During my httpd.conf, I'm getting the next additional lines in the finish of file.
LoadModule wsgi_module modules/mod_wsgi-win32-ap22py27-3.3.so WSGIScriptAlias / "C:/Projects/Folder/web/" <Directory "C:/Projects/Folder/web"> AllowOverride None Options None Order deny,allow Allow from all </Directory>
After I execute the next
index.py scripts in Home windows through http://localhost/script/index.py
def application(environ, start_response): status = '200 OK' output = 'Hello World!' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]
Works pretty fine.
However, after i add
import utils in the first type of
index.py, I recieve
ImportError: No module named utils
utils.py is same directory as
Can there be any extra configuration I have to set?
I attempt suggestion distributed by @serta_waterworth
import sys, os sys.path.append(os.path.dirname(__file__))
I recieve forget about error by posting my very own module. However, after i import module that is being installed through easy_install, error happens.
File "C:/Projects/Folder/web/script\\connection.py", line 1, in <module> import psycopg2 File "build\\bdist.win32\\egg\\psycopg2\\__init__.py", line 65, in <module> from psycopg2 import tz ImportError: cannot import name tz
import psycopg2 performed not a problem, if the script has been performed as stand alone application.
I've found that I must give a couple of lines to append the python path. Something similar to:
import sys, os sys.path.append(os.path.dirname(__file__)) import utils
for that second part, just add more lines for the import sites. ie:
sys.path.append([enter path here])
to locate your import sites, type into an interactive python prompt:
import sys print sys.path
sys.modules to check on if the directory is really added like a module directory. Otherwise