porterjamesj/virtualenvwrapper.el

Error when runnig python in eshell

Closed this issue · 6 comments

I'm trying to use eshell with virtualenvwrapper. I use venv-workon to activate my virtualenv and it works fine. I go to eshell and I configured the prompt and everything seems ok so far because the prompt shows the right virtualenv.

If I execute my script like "python main.py", it does not work because that python is not executed in the virtualenv and libraries are not installed. If I execute deactivate it works, but if I run activate it shows the message:

Error: activate must be sourced. Run 'source activate envname' instead of 'activate envname'.

I have configured virtualenvs according to the docs and all the other stuff works. But I'd like to use eshell to run my script for testing purposes. ¿Any clue with what's the problem here?.

Thanks for any help.

Sorry for long reply! This does indeed sound like a bug. Can you paste the output of running echo $PATH in eshell after you workon your virtualenv?

Hi, thanks for the reply.
This is the output of PATH in eshell:

/home/ark/envs/facture2_venv/bin:/home/ark/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

If I execute python in eshell and "import django" it returns "No module named django".

If I activate the same virtualenv in an ansi-term in emacs and import django in python it works fine and the PATH is the same for eshell.

huh, that's bizarre—that path looks correct to me. What's the output of which python in both cases?

They're different:
eshell
/home/ark/anaconda3/bin/python

ansi-term
/home/ark/envs/facture2_venv/bin/python

ahh, wait—I think eshell might use the eshell-path-env variable rather than the process environment's PATH. Can you paste the output of (message eshell-path-env) when run from an eshell?

Also I realized I should have asked this earlier—are you sure you called venv-initialize-eshell before opening the shell?

This is the output:

/home/ark/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

I use prelude and I have in my personal configuration the (venv-initialize-eshell). Anyway, I killed the eshell buffer, executed the venv-initialize-eshell, executed the venv-workon function and I get the same output for eshell-path-env.

But I tested something. While being in the eshell buffer, I ran venv-workon and the output was correct:
/home/ark/envs/facture2_venv/bin:/home/ark/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

I usually run venv-workon while being in a python file in my project and then I go to eshell and it shows the correct environment in the prompt but the PATH seems wrong. Do I have to run venv-workon again?.

Many thanks for the help.