1

I use my .bash_profile to add a directory to PYTHONPATH

export PYTHONPATH="${PYTHONPATH}:/Users/selah/newdir"

In my Anaconda installation of Spyder the path I added does not show up when I type:

import sys
sys.paths

However when i do the same in Jupyter notebook, or terminal python it does show up.

Why the discrepancy? Is there a way to get Spyder to recognize my modified PYTHONPATH?

Selah
  • 7,728
  • 9
  • 48
  • 60

2 Answers2

3

(Spyder developer here) You need to start Spyder from the command line for your changes to be detected by Spyder.

This is because Spyder doesn't have a way to read your environment variables when started in a graphical way.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
  • Is it possible to explain why Spyder can't read environmental variables when started in a graphical way? Just curious. – Selah Jul 26 '17 at 15:47
  • 1
    I think that's because variables that you define in your `.bash_profile` are not passed to applications that are not started using a shell. – Carlos Cordoba Jul 26 '17 at 17:41
2

I had a similar problem. For future reference, resolved by adding path under menu “python > PYTHONPATH manager” option.

jamalin
  • 76
  • 3