Hello,
I am user of ubuntu and I run many scripts written with python3 which was installed through anaconda. All modules that I need have been installed there previously i.e. biopython. However, I can't import biopython in one of my script when I try to run my script from /usr/lib/cgi-bin
from Bio import SeqIO #it doesn't work
The ERROR is:
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
ImportError: No module named 'Bio'
args = ("No module named 'Bio'",)
msg = "No module named 'Bio'"
name = 'Bio'
path = None
with_traceback = <built-in method with_traceback of ImportError object>
I have tried the advices proposed on Why can't python find some modules when I'm running CGI scripts from the web? or https://www.raspberrypi.org/forums/viewtopic.php?t=50225
In the first case, sudo permissions to www-data create a warning of security because I am using the server from a public institution. The second case is for raspberrypi
Can someone help me with that problem?
Did you made the python file executable and if yes are you not using a wrong shebang line?
Some extra info to do some easy checks:
Execute from the command line:
If it says that you are using the one from conda your are good, if not you now know your problem.(tip: check your $PATH)
Next start python3 from the commandline by simply executing:
If you are inside the python3 program you can type and press enter:
If you get an import error biopython is not installed. If you don't get an error biopython works and your script should work if you execute:
And the last thing but is unlikely, make sure there is no python3 symlink in your /usr/lib/cgi-bin folder.
Are you sure the
cgi-bin
python binary is 'pointing at' theconda
python binary? I suspect youre packages are set up for the 'wrong' Python.I am not sure, could you help me. Do you know how can I check that?
A quick way to check would be make a script inside the
cgi-bin
, which prints the system executable:If that prints a path with
anaconda
, then it will be another issue.Webservers are not an area of expertise for me though, so someone else will probably also need to weigh in.
I guess that my problem is: I don't know how to share anaconda packages with the user of HTTP server because the HTTP server executes my scripts as user “nobody”.
I suspect that is more likely the case.
This question is probably better directed at StackOverflow. I won’t go so far as to close it just yet, in case there is some behaviour specific to BioPython, but I doubt thats likely to be so.
This is more a question about web server config/package management than bioinformatics at this point.
Ok, I agree. I sent the same question to StackOverflow but nobody answered me with a real solution.