Article View: gnu.emacs.help
Article #1Re: Eshell and Python venv
From: Rust Buckett
Date: Thu, 30 Jul 2026 23:15
Date: Thu, 30 Jul 2026 23:15
41 lines
2996 bytes
2996 bytes
Rust Buckett <rsstinnett@pm.me> writes: > Manuel Giraud <manuel@ledu-giraud.fr> writes: > >> Rust Buckett <rsstinnett@pm.me> writes: >> >>> Is there a way to activate a Python virtual environment in Eshell? When >>> I try `source ./.venv/bin/activate`, I get "Wrong type argument: listp, >>> "["". Obviously, this is because `source` is built into the shell >>> (bash, csh, fish, eshell, etc.) and the default activate is for bash. >>> So, I guess the real question is if there is already a script to >>> activate the venv in eshell? Or some other way to do it? >> >> If you read "./.venv/bin/activate", you'll see that what it do mostly is >> setting VIRTUAL_ENV to "./venv" and add "$VIRTUAL_ENV/bin" to your PATH >> to access the "correct" python. >> >> So doing the following should work: >> export VIRTUAL_ENV="/absolute/path/to/venv" >> export PATH="$VIRTUAL_ENV/bin":$PATH >> >> But maybe you could come up with an elisp function to more easily >> activate (and deactivate) those. > > I realized that since you can evaluate elisp functions in eshell as you > would commands, I'm able to run `pyvenv-activate .venv` right in the > shell. This /almost/ works. `exec-path` shows the correct path and > `getenv "PATH"` shows the change, but `echo $PATH` does not. Guess > which one eshell uses. > > If I run `pyvenv-activate .venv` then exit eshell and start it again, > everything works. It's not as elegant as I would like, but I guess it > will have to do. I haven't been on usenet in a while and ran across this thread. The solution that I went with after a rather lengthy conversation on IRC #emacs, was to create an alias called reload in eshell that evaluates `(eshell/export (concat "PATH=" (string-join exec-path ":")))`. -- this is my clever sig.
Technical Details
Message-ID:
<8733x0f4rz.fsf@pm.me>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mailReferences:
<87ecnwn6h4.fsf@pm.me> <87ms2kid4p.fsf@ledu-giraud.fr> <87a4ykmk11.fsf@pm.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Rust Buckett <rsstinnett@pm.me> Newsgroups: gnu.emacs.help Subject: Re: Eshell and Python venv Date: Thu, 30 Jul 2026 19:15:28 -0400 Organization: A noiseless patient Spider Lines: 41 Message-ID: <8733x0f4rz.fsf@pm.me> References: <87ecnwn6h4.fsf@pm.me> <87ms2kid4p.fsf@ledu-giraud.fr> <87a4ykmk11.fsf@pm.me> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Thu, 30 Jul 2026 23:15:29 +0000 (UTC) Injection-Info: dont-email.me; logging-data="2328098"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18izKPbn8yYtc/3O3p4L2GMlbIuU4GTfUU="; posting-host="09a9e5a71a72ba3f65d9801cba202a98" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:ELI536TLYhBte6kYLMDn+6O4A3I= sha1:YyAtRNtG9jaFJHE/z3AdcrP51k0= sha256:N6vzoF2GimvnbUcjxla/MmF0RKepBJ/NIwZJ1xl1eHw= sha1:1V6txW0BQrqcQyG99mVTMS/SFeE= sha256:Pr28YX3hhYW6KLt0/nHi8JUzSi3e17PutIgYm2JCZeo=