Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyenv activate does not run activate script with Fish Shell

My pyenv is working just fine, but it does not seem to be running my activate script located at /usr/local/var/pyenv/versions/project/bin/activate.fish

When activating my environment it gives the following output, but it does not echo anything from the activate script, which indicates that it is not running.

dani@localhost ~/d/project> pyenv activate project
pyenv-virtualenv: prompt changing not working for fish.

Of course I can just source the file manually, but I'm too eager to find out why it is not running. Is there some kind of debug mode? I'm not sure how to approach.

like image 308
Dani Avatar asked Mar 08 '17 13:03

Dani


People also ask

Why doesn't pyenv work in fish?

There are some mentions of fish on wiki, but currently pyenv does not work in it. Namely, the problem is pyenv init, which tries to perform a bash eval inside fish, which, of course, fails. Installation/uninstallation of Python versions seems to work normally.

Does Eval (pyenv init-fish) return'SH-'?

Since eval (pyenv init - fish) returns pyenv: no such command sh-'. Sorry, something went wrong. Oops. You're right. The initialization code has been changed during exporting this feature to rbenv ( rbenv/rbenv#434 ). Now I'm using following initialization code. Sorry, something went wrong. For posterity: pyenv now supports fish!

How to activate virtualenv from a script?

The virtualenv activates by sourcing (not normally running) the virtualenv/bin/activate script. If you want to do this in your own script, then you must source that script too and not just run it. Meaning:

Is pyenv written in bash or Linux?

Many of the code of pyenv is written in bash, but there are some of interactions between working shell. They might be the problem to support fish. Sorry, something went wrong. I'd personally be happy if init worked, I don't really use 2 or 3.


2 Answers

try this:

set PYENV_ROOT $HOME/.pyenv
set -x PATH $PYENV_ROOT/shims $PYENV_ROOT/bin $PATH
pyenv rehash
like image 27
fuxiang Avatar answered Nov 18 '22 00:11

fuxiang


Actually,

Virtual environment is activated but the message just says that your prompt wasn't changed. Updating prompt was intentionally removed from fish shell. you can find detailed information here; https://github.com/pyenv/pyenv-virtualenv/issues/153

If you want to see virtual environment is really activated or not, run the following command;

pyenv which python

it should print something like; .pyenv/versions/{your-virtual-env}/bin/python

like image 64
korkmaz Avatar answered Nov 18 '22 00:11

korkmaz