Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: can't activate python virtual environment #14969

Open
Marat22 opened this issue Jan 30, 2025 · 1 comment
Open

BUG: can't activate python virtual environment #14969

Marat22 opened this issue Jan 30, 2025 · 1 comment
Labels
needs-triage An issue that hasn't had any proper look windows A Windows specific issue

Comments

@Marat22
Copy link

Marat22 commented Jan 30, 2025

Describe the bug

if i run this command in nu...

C:\marat\programs\BASE\MiriadRobot>nu
C:\marat\programs\BASE\MiriadRobot> venv\Scripts\activate.bat
C:\marat\programs\BASE\MiriadRobot> python -c "import sys; print(sys.executable)"
C:\Users\ir2\AppData\Local\Programs\Python\Python312\python.exe                                                                                                                                                                                 30.01.2025 15:33:08

...my python virtual environment doesn't activate.

However, if i activate virtual environment before starting nu...

C:\marat\programs\BASE\MiriadRobot>venv\Scripts\activate
(venv) C:\marat\programs\BASE\MiriadRobot>nu
C:\marat\programs\BASE\MiriadRobot> python -c "import sys; print(sys.executable)"
C:\marat\programs\BASE\MiriadRobot\venv\Scripts\python.exe

... everything is ok

How to reproduce

  1. Try to activate venv in nu
C:\marat\programs\BASE\MiriadRobot> venv\Scripts\activate.bat
  1. Print path of python executable
C:\marat\programs\BASE\MiriadRobot> python -c "import sys; print(sys.executable)"
C:\Users\ir2\AppData\Local\Programs\Python\Python312\python.exe          

Expected behavior

I expected that if I run

C:\marat\programs\BASE\MiriadRobot> venv\Scripts\activate.bat

... my python environment activates

C:\marat\programs\BASE\MiriadRobot> python -c "import sys; print(sys.executable)"
C:\marat\programs\BASE\MiriadRobot\venv\Scripts\python.exe

Configuration

key value
version 0.101.0
major 0
minor 101
patch 0
branch
commit_hash
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.83.0 (90b35a623 2024-11-26)
rust_channel stable-x86_64-pc-windows-msvc
cargo_version cargo 1.83.0 (5ffbef321 2024-10-29)
build_time 2025-01-20 08:30:19 +05:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash
installed_plugins
@Marat22 Marat22 added the needs-triage An issue that hasn't had any proper look label Jan 30, 2025
@sholderbach
Copy link
Member

This command won't work like this as you are launching a batch script which will spawn a CMD.exe process sets the environment in that and then leave, all while the Nushell shell above never gets the environment changes.

Not quite sure about the virtualenv specific things on Windows but a

overlay use venv/bin/activate.nu

sounds more like the way we handle that. (may be the path is still venv/Scripts on windows?)

@sholderbach sholderbach added the windows A Windows specific issue label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage An issue that hasn't had any proper look windows A Windows specific issue
Projects
None yet
Development

No branches or pull requests

2 participants