user2327814
user2327814

Reputation: 543

Trouble adding environment variables to $PYTHONPATH in linux

So I want to add some code to my python path the code is located in $HOME/eon on my machine. I was told to add:

export PYTHONPATH=$HOME/test:$PYTHONPATH
export PATH=$HOME/test/bin:$PATH

to ~/.profile. However this does not work for me. When I type those two lines into the terminal I do add the test folder to my python path but only temporarily. I have also tried adding the two lines to my ~/.bashrc file but still no luck.

Upvotes: 1

Views: 251

Answers (2)

Sait
Sait

Reputation: 19845

  1. Add them in ~/.profile
  2. Save and exit
  3. Do source ~/.profile to make changes effective for the current bash

If you are still having problems, you can add echo 'hello world.' to your .bashrc and see if it prints it when you open a new terminal to see if your system runs .bashrc as it should be.

Upvotes: 1

Ami Tavory
Ami Tavory

Reputation: 76396

What you're doing works fine on my system, so it's possible you forgot to "tell the system" to use the new version ~/.bashrc

Here is the output from my terminal after adding your lines to my ~/.bashrc:

/home/amit/test/bin:/home/amit/test/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/amit/bin

The changes are not reflected. However, after

[amit@amit ~]$ source ~/.bashrc 

I get:

[amit@amit ~]$ echo $PATH
/home/amit/test/bin:/home/amit/test/bin:/home/amit/test/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/amit/bin

Upvotes: 1

Related Questions