Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.emacs.help > #61044 > unrolled thread
| Started by | Rust Buckett <rsstinnett@pm.me> |
|---|---|
| First post | 2026-01-10 23:00 -0500 |
| Last post | 2026-07-30 19:15 -0400 |
| Articles | 4 — 2 participants |
Back to article view | Back to gnu.emacs.help
Eshell and Python venv Rust Buckett <rsstinnett@pm.me> - 2026-01-10 23:00 -0500
Re: Eshell and Python venv Manuel Giraud <manuel@ledu-giraud.fr> - 2026-01-11 12:48 +0100
Re: Eshell and Python venv Rust Buckett <rsstinnett@pm.me> - 2026-01-11 07:05 -0500
Re: Eshell and Python venv Rust Buckett <rsstinnett@pm.me> - 2026-07-30 19:15 -0400
| From | Rust Buckett <rsstinnett@pm.me> |
|---|---|
| Date | 2026-01-10 23:00 -0500 |
| Subject | Eshell and Python venv |
| Message-ID | <87ecnwn6h4.fsf@pm.me> |
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? -- this is my clever sig.
[toc] | [next] | [standalone]
| From | Manuel Giraud <manuel@ledu-giraud.fr> |
|---|---|
| Date | 2026-01-11 12:48 +0100 |
| Message-ID | <87ms2kid4p.fsf@ledu-giraud.fr> |
| In reply to | #61044 |
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. -- Manuel Giraud
[toc] | [prev] | [next] | [standalone]
| From | Rust Buckett <rsstinnett@pm.me> |
|---|---|
| Date | 2026-01-11 07:05 -0500 |
| Message-ID | <87a4ykmk11.fsf@pm.me> |
| In reply to | #61045 |
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. -- this is my clever sig.
[toc] | [prev] | [next] | [standalone]
| From | Rust Buckett <rsstinnett@pm.me> |
|---|---|
| Date | 2026-07-30 19:15 -0400 |
| Message-ID | <8733x0f4rz.fsf@pm.me> |
| In reply to | #61046 |
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.
[toc] | [prev] | [standalone]
Back to top | Article view | gnu.emacs.help
csiph-web