I am using Eclipse as my python environment. I am using an anaconda environment to install all of my python interpreters and other software for this work I am doing. I have successfully pointed PyDev to the right interpreter to use (the miniconda environment one, not the system one). However, one of the functions I am using opens up a command line inside python, and this is in the wrong environment (my system environment, and not my miniconda environment). I am looking for one of two solutions:
- Way of getting PyDev to use the Anaconda environment even for cmd line calls
- Way of getting a python script to go into an Anaconda environment.
To make it more complex, I have limited control over the cmd line function, so cannot use the suggestion in questions such as How do you activate an Anaconda environment within a Python Script? and Activate a Conda Environment in Python Script
Here is the code I have used so far:
from Bio.Blast.Applications import NcbiblastnCommandline
from io import StringIO
import os
cline = NcbiblastnCommandline( query="sequence.fa",
db="contigs.fa",
evalue=0.01,
outfmt=5
)
stdout, stderr = cline()
fp = StringIO( stdout )
blast_records = [r for r in NCBIXML.parse( fp )]
And the error message is the following (as it is only installed in my miniconda environment)
Bio.Application.ApplicationError: Non-zero return code 127 from 'blastn -outfmt 5 -query sequence.fa -db contigs.fa -evalue 0.01', message '/bin/sh: 1: blastn: not found'
My question is as above - I am looking for one of two solutions:
- Way of getting PyDev to use the Anaconda environment even for cmd line calls
- Way of getting a python script to go into an Anaconda environment.
Usually when running in PyDev the conda env would be properly activated if you have configured to do so...
Can you check whether you have it checked there? (see screenshot below)
Some things to check if whether your
PATHvariable is actually correct by just activating the environment and that what you want to launch is there (it's also possible that what you're using for creating the command line isn't really passing the environment as expected).