Export of PYTHONPATH from .zshrc not working
This export $PYTHONPATH
is incorrect.
export
takes variable names not values.
You want export PYTHONPATH
.
Your line is equivalent to export /Users/nicolas/Code:/Users/nicolas/Code/Dashboard
which, as you might be able to tell, isn't very useful.
Related videos on Youtube
knightofni
Updated on May 25, 2022Comments
-
knightofni almost 2 years
I'm trying to export the PYTHONPATH environment variable from my .zshrc, but fails.
relevant lines from .zshrc
PYTHONPATH="/Users/nicolas/Code:/Users/nicolas/Code/Dashboard" export $PYTHONPATH
** from the command line **
1] test one
echo $PYTHONPATH /Users/nicolas/Code:/Users/nicolas/Code/Dashboard
appears to work
2] test two
`sh -c 'echo "$PYTHONPATH"' ` ==> empty output
actually doesnt
3] test three
running the folloing python script, with the command
python script.py
#!/usr/bin/env python import os try: user_paths = os.environ['PYTHONPATH'].split(os.pathsep) except KeyError: user_paths = 'no pythonpath' print user_paths
outputs : no pythonpath
fails again
4] test four
zsh -x -c 'echo moo' +/etc/zshenv:2> [ -x /usr/libexec/path_helper ']' +/etc/zshenv:3> /usr/libexec/path_helper -s +/etc/zshenv:3> eval 'PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/opt/X11/bin:/usr/texbin:/Users/nicolas/anaconda/bin:/opt/local/lib/postgresql93/bin:/Users/nicolas/Code/games:/Users/nicolas/Code/Dashboard";' export 'PATH;' +(eval):1> PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin:/opt/X11/bin:/usr/texbin:/Users/nicolas/anaconda/bin:/opt/local/lib/postgresql93/bin:/Users/nicolas/Code/games:/Users/nicolas/Code/Dashboard +(eval):1> export PATH +zsh:1> echo moo moo
extra info :
which zsh
outputs : /usr/local/bin/zsh
My $PATH is ok, it's perfectly similar from the terminal and from inside python.
What is happening, and how can i solve this ?
Using Mac os, python installed from anaconda
-
knightofni about 9 yearsThanks. This kind of small mistake is hard to find when new to *nix environment.
-
Etan Reisner about 9 yearsYou should have seen an error from your shell when trying to execute that line because that expanded
export
line is not legal. (Try it in a running shell to see what I mean.) Though it is possible that was being sent somewhere you couldn't see (or didn't know to look). -
knightofni about 9 yearsYeah, there was an error when loading the shell. But because echo $PYTHONPATH returned something that looked like a path, i didn't pay heed to that warning...