OS: macOS Sierra Beta 6 Python: 2.7 Shell: Fish

I am having issues with my PYTHONPATH environmental variable being set correctly.

In my fish_config file, I have this line setting up PYTHONPATH:

set -gx PYTHONPATH "/opt/additionalPath" "/usr/local/lib/python2.7/site-packages";

But when I launch python, I get this output when I try to look at the path:

>>> import sys
>>> print sys.path
['', '/opt/additionalPath\x1e/usr/local/lib/python2.7/site-packages', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages', '/Library/Python/2.7/site-packages']

Notice the \x1e between the paths that I am adding.

If I launch the bash shell from fish and echo $PYTHONPATH, I get this output:


I know that those paths are supposed to be separate by a colon but I can't figure out where that is being done. My theory is that something in the bash shell is setting the path in the fish shell but I am running out of ideas.

Any help would be much appreciated.

You can't use a list in fish for PYTHONPATH, you have to use a single string with : as a separator as you would do in bash:

set -gx PYTHONPATH "/opt/additionalPath:/usr/local/lib/python2.7/site-packages"

See this bug report for some more info.

  • Also, if you're using fish 2.3.0 or newer, and thus can use the new string builtin, you can do it this way: set -gx PYTHONPATH (string join : /opt/additionalPath /usr/local/lib/python2.7/site-packages) – Kurtis Rader Aug 19 '16 at 21:37

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.