I am using Mapnik v2.2.0 for Python 2.7 (32 bit - Anaconda distribution) at the moment and I wanted to use it in a rudimentary CGI script. The mapnik is definitely installed correctly as it runs without errors if launched straight from Python. However, when I launch one script through another, it gives an
ImportError: No module named mapnik
In other words, consider code:
import CGIHTTPServer, BaseHTTPServer address = ('', 8000) handler = CGIHTTPServer.CGIHTTPRequestHandler server = BaseHTTPServer.HTTPServer(address, handler) server.serve_forever()
print '<form method="POST" action="Script3.py">'
Then, accessing 127.0.0.1:8000/Script2.py launches Script3, which then gives an ImportError.
Is there some compatibility issue about external Python modules being called through CGI?
Is that a problem with Anaconda in particular?
I have partially resolved the issue - copying mapnik to Anaconda directory solved it. HOWEVER, now when the CGI script tries to create a postgis datasource, it returns a Runtime Error. Now, I don't know if PostgreSQL and Postgis somehow bootstrap themselves to the mapnik installation/its original location and trying to call it from what they deem to be a 'different' mapnik fails... Creating the postgis datasource works fine if I do it straight from Python. Thus the problem persists:
Does Anaconda introduce any compatibility/package visibility problems in running its Python scripts as CGI scripts?