The following works in bash:
~$ echo $PYTHONPATH
<nothing>
~$ export PYTHONPATH=/path/to/test/folder
~$ echo $PYTHONPATH
/path/to/test/folder
~$ python -m test_script
hello world
But not in fish:
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
~> echo $PYTHONPATH
<nothing>
~> set --universal PYTHONPATH /path/to/test/folder
~> echo $PYTHONPATH
/path/to/test/folder
~> python -m test_script
/usr/bin/python: No module named test_script
I've tried set
, set --global
and set --universal
.
How can I set PYTHONPATH in fish? (If it matters, I'm running Ubuntu 14.04.)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With