0

I am trying to get a python cgi script working on Apache 2.2.

I have reporting.cgi in cgi-bin and its working fine.

import sys
import os
import clr
import pypyodbc
import cgi.

# HTML Header
print '<html>'
print '<head>'
print '<link rel="stylesheet" href="../html_docs/epydoc.css" type="text/css" />'
print '<meta http-equiv="Content-Type"  content="text/html; charset=UTF-8" />'
print '<title>Test Framework</title>'
print '</head>'
..
...
..

However, there's other Python modules I need to use on a network drive. (genutils.py)

So I try to import the location and import genutils.py.

sys.path.insert(0, 'I:/swd/Shared/Python')
import genutils

However, now when I try to call my webpage I get

[Mon Oct 07 14:02:25 2013] [error] [client 10.70.26.3]   File "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cgi-bin/reporting.cgi", line 23, in <module>\r\r
[Mon Oct 07 14:02:25 2013] [error] [client 10.70.26.3] ImportError: No module named genutils.

I've also sys.path.append and not using drive letters (//machine/dir/swd/shared/python)

Any advice is much appreciated.

Thanks.

3
  • It looks like you're running on Windows. Presuming Apache is running as a service, you will need to make sure that the account which Apache is running under can access the network resources it requires. A better practice, IMHO, is to deploy the complete software stack on the server where it's needed. That way you have less dependencies between servers. Oct 7, 2013 at 13:43
  • True, I am on windows.
    – John
    Oct 7, 2013 at 13:58
  • This looks like the reason. If I move the file I need to a local directory it works fine. So I can run locally (which is unlikely as as its a shared python file or provide a secure way or granting my Apache service network access (not very secure)
    – John
    Oct 7, 2013 at 14:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.