-1

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

You can see the ERROR in this page http://pegaso.microbiologia.ull.es/cgi-bin/hello.py which is my server.

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

How can I fix the problem??

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". How can I do that?

  • it sounds like Biopython not installed (on the version of Python you're running at least), you can look-up how to do that, but try `pip install biopython --user` – Chris_Rands May 13 '19 at 12:07
  • This is the exact same question as [the other you've referenced](https://stackoverflow.com/q/3783887/570918). In order not to close your question as a duplicate, you need to show us what happened when you tried implementing each of the solutions from that other question. Saying you tried them is not enough, and many of the suggestions there are aimed at providing better debugging information so that we can help you better. Please edit your question to show what you've done. – merv May 13 '19 at 16:32
  • First of all, change www-data on export APACHE_RUN_USER doesn't work because the webserver uses the user www-data, and that's what it run it as. Second, python and its modules have been installed through anaconda. Third, python run ok and many modules but not biopython. Indeed, biopython was difficult to install with anaconda – Laura Hernández Javier May 14 '19 at 07:44
  • In cd /etc/profile.d, I created a file named anaconda.sh with the contents PATH=/mypath/anaconda/bin:$PATH. According to anaconda documentation that should be enough to share anaconda with many users. However, I have the same problem, ImportError: No module named 'Bio' – Laura Hernández Javier May 15 '19 at 14:13

1 Answers1

1

SOLUTION: Removing anaconda from home directory and install it in usr/local. Thus, Apache will have permission to access the environment.

a) Remove anaconda with $ rm -rf anaconda3/ b) Re-install anaconda3 in directory /usr/local c) Add the line export PATH='/usr/local/anaconda3/bin:$PATH' to the end of your /root/.bashrc file d) Verify that the root user is using the right version of Python: $ which python

That's all