Import Bio module from Bash
1
1
Entering edit mode
2.1 years ago
Michal Nevo ▴ 130

I'm working on a remote server with Linux. I created a new environment and got biopython installed with conda:

conda create --name new_bio python=3.5
conda activate new_bio
conda install -c conda-forge biopython

import Bio works when I am running it inside python:

(new_bio) -bash-4.2$ python
Python 3.5.5 | packaged by conda-forge | (default, Jul 23 2018, 23:45:43)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import Bio
>>> exit()

import Bio works when I am running my script like this:

(new_bio) -bash-4.2$ python my_Bio_script.py
hello

my_Bio_script.py:

from Bio import SeqIO
print('hello')

But when I try to run my script with Bash :

(new_bio) -bash-4.2$ sbash my_bash.sh 

my_bash.sh bash file:

#!/bin/bash
module load anaconda           ### load anaconda module
source activate new_bio        ### activating environment, environment 
must be configured before running the job


python my_Bio_script.py

I get this error:

Traceback (most recent call last):
File "T.py", line 1, in <module>
from Bio import SeqIO
ModuleNotFoundError: No module named 'Bio'

I have to send it as a Slurm Job in a bash file.. what can I do?

bash biopython Slurm • 657 views
ADD COMMENT
1
Entering edit mode
2.1 years ago

Your conda environment is not activating properly when you start a new bash shell

see the following recent post for solutions

Why piping a conda command into bash doesn't work ?

ADD COMMENT

Login before adding your answer.

Traffic: 2946 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6