问题
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?
回答1:
(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.
回答2:
I had a similar problem. For future reference, resolved by adding path under menu “python > PYTHONPATH manager” option.
来源:https://stackoverflow.com/questions/45086454/modified-pythonpath-not-recognized-by-anaconda-spyder