Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do system variables update in IPython kernel?

I started a notebook by doing jupyter notebook, and then creating a new notebook.

Then, I went to the terminal, and I set the PATH:

export PATH=$PATH:<absolute path>

But, then when I go back to the IPython notebook, I try to print this new system variable:

import os
print(os.environ["PATH"].split(os.pathsep))

But, I don't see my <absolute path> that I just added??

I even tried restarting the kernel, but this doesn't help at all. What can I do? Thank you.

EDIT:

I tried to refresh my environmental variables via the terminal by doing: bash --login, but this did not help at all.

Also, another thing that is peculiar about this is that when I add it to the system path manually in ipython:

os.environ['PATH'] = os.environ['PATH'] + os.pathsep + <absolute path>

...it works fine in the notebook and kernel where I added it. But, when I spin up another IPython kernel, it isn't on the PATH anymore.

I'm on osx.

like image 515
makansij Avatar asked Feb 17 '26 23:02

makansij


1 Answers

When you do

export PATH=$PATH:<absolute path>

in a terminal, it is only effective in this terminal session. That is to say, this export command has no effect on other terminal sessions.

If you want your PATH environment to be effective all the way, you need to edit your .bashrc file, and

source ~/.bashrc

to activate it.

like image 108
rojeeer Avatar answered Feb 20 '26 12:02

rojeeer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!