sayth
sayth

Reputation: 7048

PYTHONPATH error Linux Terminal v Console

I am having trouble getting PYTHONPATH set. I have added this line to ~/.bashrc

export PYTHONPATH=$PYTHONPATH:/home/sayth/My_Programs/Python

I ran source ~/.bashrc

Here is the issue though if I type python at the terminal and get a python REPL I can then import modules from ~/My_Programs/Python without a problem.

However if I run bpython or idle or a console in ninja-ide etc then import fails.

>>> import temperature
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import temperature
ImportError: No module named temperature
>>> 

I can do sys.path.append(/home/sayth/My_Programs/Python) and get it working, but I wanted the PYTHONPATH to work in all consoles automatically. How?

PS using ubuntu 11.10

Upvotes: 2

Views: 635

Answers (1)

sarnold
sarnold

Reputation: 104050

I'm going to guess that you did not launch your ninja-ide from the same terminal that you source ~/.bashrc from -- the new environment variable only influences child processes of whichever shell process did the sourcing. Of course, logging out and in again may do it, but if you're living entirely in the GUI (e.g., you click a button to start the ninja-ide), then you may need to go to some more effort to set your environment variable. How you do so depends upon which graphical environment you're using.

Upvotes: 3

Related Questions