How can I set PYTHONPATH in fish?

泪湿孤枕 提交于 2019-12-04 08:51:33

Setting the variable is not sufficient, you must export it too (as you do in bash). Exporting means that subprocesses (like the Python call) will get the value too.

From the fish documentation:

-x or --export causes the specified environment variable to be exported to child processes

So a direct equivalent to the bash directive would be:

~> set --export PYTHONPATH /path/to/test/folder

You could add --universal or other arguments, but here the value is temporary, which matches the original bash example.

(Found answer via a similar question.)

If you want to make the change permanent then you can add the following line

set -xg PYTHONPATH /path/to/test/folder $PYTHONPATH

to the bottom of ~/.fish/config.fish

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!