PYTHONPATH - what's wrong?
0
0
Entering edit mode
4.6 years ago
tanya_fiskur ▴ 70

Hello!

I have the next issue: The program that I need to use (SQANTI) requires adding cDNA_Cupcake/sequence/ into the PYTHONPATH by

(anaCogent3)-bash-4.1$ export PYTHONPATH=$PYTHONPATH:<path_to>/cDNA_Cupcake/sequence/

I did it by

export PYTHONPATH=$PYTHONPATH:/home/smrtanalysis/cDNA_Cupcake/sequence/

The pythonpath was clear (according to the echo $PYTHONPATH) before that. However, running the program I saw the next error:

Unable to import err_correct_w_genome or sam_to_gff3.py! Please make sure cDNA_Cupcake/sequence/ is in $PYTHONPATH.

After a number of various manipulations I have the output of echo$PYTHONPATH like this:

/home/smrtanalysis/cDNA_Cupcake/sequence/:/home/smrtanalysis/cDNA_Cupcake/sequence

And the program still outputs the same error.

What is wrong with it?

Is it possible to clear the pythonpath to the initial state, like before I did all the manipulations, without rebooting?

Should the echo$PYTHONPATH output start with "bash: echo/home..."?

Thank you in advance!

SQANTI Python • 2.4k views
ADD COMMENT
1
Entering edit mode

You don't need to reboot to clear the changes. Simply log out and back in, or open a new terminal. However, I think you should make the export changes permanent by putting them into your .bashrc file so you don't have to type them for each session.

The command you used:

export PYTHONPATH=$PYTHONPATH:/home/smrtanalysis/cDNA_Cupcake/sequence/

assumes that $PYTHONPATH was already defined. If you are sure that it wasn't, the following command should be in your .bashrc file:

export PYTHONPATH=/home/smrtanalysis/cDNA_Cupcake/sequence/

Any time after the initial definition of $PYTHONPATH you decide to add new entries to it is when you would include $PYTHONPATH: in your export command.

As to why it doesn't work, either you are not adding a correct path - meaning err_correct_w_genome and sam_to_gff3.py are not in that directory - or the change you are making to this variable are not seen somehow when you run the program. That is another reason to define this variable globally in .bashrc so it is always there.

ADD REPLY
0
Entering edit mode

Thank you for your reply! Now I have checked the .bashrc file, and saw nothing about the PYTHONPATH variable. I have added the

export PYTHONPATH=$PYTHONPATH:/home/smrtanalysis/cDNA_Cupcake/sequence/

after all the exiting

export PATH=$PATH:/home/smrtanalysis ....

commands, and saved. The program still doesn't see the needed .py files. I also tried to add

export PYTHONPATH=/home/smrtanalysis/cDNA_Cupcake/sequence/

but it didn't help.

Running

source ~/.bashrc

after that - too.

Did I put the command into the correct place of the .bashrc file? The files exist in the "/home/smrtanalysis/cDNA_Cupcake/sequence/" directory

ADD REPLY
1
Entering edit mode

Again, the first time you are defining $PYTHONPATH the export command needs to be:

export PYTHONPATH=/home/smrtanalysis/cDNA_Cupcake/sequence/

The $PYTHONPATH: part is used in that line as you add more paths to this variable, but not the very first time.

One last thing to consider is whether you are doing this in some environment (virtual, conda) that doesn't recognize $PYTHONPATH as defined in bash. If that's the case I can't help you because I only work in regular shell, but it is possible that you will have to again enter the export command after entering a non-bash environment.

ADD REPLY
0
Entering edit mode

Oh, that is weird.. I added the pythonpath being both in the conda environment where I work, and outside it. It still doesn't work. Maybe, my last suggestion: I noticed that previously the echo $PYTHONPATH command output started with "bash: echo/home/smrtanalysis....", and now it starts just with "/home/smrtanalysis/..."

Can it be the reason?

ADD REPLY

Login before adding your answer.

Traffic: 1915 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