I have no idea what could be the problem here:
I have some modules from Biopython which I can import easily when using the interactive prompt or executing python scripts via the command-line.
The problem is, when I try and import the same biopython modules in a web-executable cgi script, I get a "Import Error"
: No module named Bio
Any ideas here?
Here are a couple of possibilities:
sys.version
and sys.prefix
, and compare the result through apache and via the command line, to make sure that you're running from the same installation of python in both environments. import site
before trying to import Biopython? Perhaps something is preventing site packages from being imported when you run through apache. In the cgi script, you could try to add the path to this package before any import.
sys.path.insert(0, 'path to biopython package')
If you are using Apache, you should be able to set the PYTHONPATH in conf file with directive SetEnv
SetEnv PYTHONPATH "path to biopython package"
I had same problem. I solved this problem by changing user of Apache in Linux Ubuntu by command in terminal:
sudo gedit /etc/apache2/envvars
Please change www-data
on export APACHE_RUN_USER
and export APACHE_RUN_GROUP
to your current user or user that can run python script. Have a good time ;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.