Python .\venv\Scripts\activate.bat not work and doesn't show (.venv) flag in window terminal but work in cmd #17859

Closed
opened 2026-01-31 05:56:32 +00:00 by claunia · 5 comments
Owner

Originally created by @wonkyDD on GitHub (Jul 4, 2022).

Windows Terminal version

1.13.11431.0

Windows build number

10.0.19044.1766

Other Software

python 3.10.5

Steps to reproduce

In Window Terminal

I installed venv , named as venv, right under project directory.
image

And excuted activate.bat
image

I tried also Activate.ps1 but it just throw me error :-(

Entered, and it cleaned its page like when we type cls
image

But it doesn't show me (venv) flag like in Command Prompt

Typed same with all the things above in cmd and result below

image

There is a (venv) leftmost site diffrent from window terminal

Just In case, venv worked out but it just doesn't show (venv) in window terminal,
so I give an input pip list to check out if it works

  • In cmd

image

As virtual environment, it only showed pip and setuptools and worked well

  • In window terminal

image

Unlike in cmd, it showed all the packages I've installed using pip.
It doesn't work as virtual env :-(

What am I supposed to do? What's wrong with me?
If I forgot some details to solve this problem,
please let me know :)

Thank you for reading!

Expected Behavior

1. I want (venv) flag to show up in window terminal like in cmd

2. When I input pip list in window terminal , just want to make it give me only pip and setuptools

3. After executing .\venv\Scripts\activate.bat, when I input where.exe python , want to show me all the python paths including python in .\venv

  • In window terminal

image

  • In cmd

image

D:\dev\project\venv\Scripts\python.exe only shows up in cmd

Actual Behavior

Sorry for writing actual behavior in steps to reproduce area 🙏

Originally created by @wonkyDD on GitHub (Jul 4, 2022). ### Windows Terminal version 1.13.11431.0 ### Windows build number 10.0.19044.1766 ### Other Software python 3.10.5 ### Steps to reproduce # In `Window Terminal` I installed `venv `, named as venv, right under `project` directory. ![image](https://user-images.githubusercontent.com/81248624/177147236-63059519-894d-4c2f-85fb-8d5a1119f3f9.png) And excuted `activate.bat` ![image](https://user-images.githubusercontent.com/81248624/177147480-459e3363-a21b-4356-879c-10f97c76bff2.png) > I tried also `Activate.ps1` but it just throw me error :-( Entered, and it cleaned its page like when we type `cls` ![image](https://user-images.githubusercontent.com/81248624/177148636-f2450155-4228-497a-8f6f-2f10a246dc90.png) ## But it doesn't show me `(venv)` flag like in `Command Prompt` Typed same with all the things above in cmd and result below ![image](https://user-images.githubusercontent.com/81248624/177149338-8fb21b0b-61e8-4743-9fdf-b1900c6aa260.png) There is a `(venv)` leftmost site diffrent from `window terminal` **Just In case, venv worked out but it just doesn't show `(venv)` in window terminal,** so I give an input `pip list` to check out if it works - In `cmd` ![image](https://user-images.githubusercontent.com/81248624/177150746-4ef42142-8e2c-4423-85de-98ed93c2e0dc.png) As virtual environment, it only showed `pip` and `setuptools` and worked well - In `window terminal` ![image](https://user-images.githubusercontent.com/81248624/177151024-669a5c07-18b3-4e0e-861e-d657991bec65.png) Unlike in `cmd`, it showed all the packages I've installed using pip. It doesn't work as virtual env :-( What am I supposed to do? What's wrong with me? If I forgot some details to solve this problem, please let me know :) Thank you for reading! ### Expected Behavior ### 1. I want (venv) flag to show up in `window terminal` like in `cmd` ### 2. When I input `pip list` in `window terminal` , just want to make it give me only `pip` and `setuptools` ### 3. After executing `.\venv\Scripts\activate.bat`, when I input `where.exe python` , want to show me all the python paths including python in `.\venv` - In `window terminal` ![image](https://user-images.githubusercontent.com/81248624/177152952-adc11e86-d2bc-4dbe-9c27-7a3fcffe301e.png) - In `cmd` ![image](https://user-images.githubusercontent.com/81248624/177153122-7614cf03-64a8-4a4b-ae3b-8ce7659f0461.png) `D:\dev\project\venv\Scripts\python.exe` only shows up in `cmd` ### Actual Behavior Sorry for writing actual behavior in steps to reproduce area 🙏
claunia added the Needs-TriageIssue-BugNeeds-Tag-Fix labels 2026-01-31 05:56:32 +00:00
Author
Owner

@elsaco commented on GitHub (Jul 4, 2022):

@wonkyDD when launching a Python venv inside a powershell session you need to use activate.ps1 script. The prompt is set differently in activate.bat and activate.ps1 scripts. The former one is using set PROMPT which only works in a cmd session.

You mentioned your activate.ps1 script is failing. That needs fixing! Try running .\venv\Scripts\Activate.ps1 -Verbose to get more feedback.

You can set the name for the venv in .\venv\pyvenv.cfg also. Just add prompt = some_name and it will be used regardless what shell you launch the venv from.

@elsaco commented on GitHub (Jul 4, 2022): @wonkyDD when launching a Python venv inside a powershell session you need to use `activate.ps1` script. The prompt is set differently in `activate.bat` and `activate.ps1` scripts. The former one is using `set PROMPT` which only works in a `cmd` session. You mentioned your `activate.ps1` script is failing. That needs fixing! Try running `.\venv\Scripts\Activate.ps1 -Verbose` to get more feedback. You can set the name for the venv in `.\venv\pyvenv.cfg` also. Just add `prompt = some_name` and it will be used regardless what shell you launch the venv from.
Author
Owner

@wonkyDD commented on GitHub (Jul 4, 2022):

Thank you so much for your replying .. 🤣😂

As you mentioned , I attached -Verbose option at the end and it throw me
specified info !!

It told me like this:
image

With some search, I could smash it!

image

Again, thank you for your kindness 😊

@wonkyDD commented on GitHub (Jul 4, 2022): Thank you so much for your replying .. 🤣😂 As you mentioned , I attached `-Verbose` option at the end and it throw me specified info !! It told me like this: ![image](https://user-images.githubusercontent.com/81248624/177189533-d0f2b24c-fba8-4b3b-af83-e2d8d36e0465.png) With some search, I could smash it! ![image](https://user-images.githubusercontent.com/81248624/177189295-12e5ad66-a5b9-4132-8040-fde1a5860b99.png) Again, thank you for your kindness 😊
Author
Owner

@ewwink commented on GitHub (Feb 24, 2024):

in case you want to open terminal using launcher.bat

CMD

wt -d "D:\dev\project" "cmd /k venv\Scripts\activate"

PowerShell

wt -d "D:\dev\project" -p "Windows PowerShell" "powershell -NoExit  venv\Scripts\activate"

source

@ewwink commented on GitHub (Feb 24, 2024): in case you want to open terminal using `launcher.bat` CMD ``` wt -d "D:\dev\project" "cmd /k venv\Scripts\activate" ``` PowerShell ``` wt -d "D:\dev\project" -p "Windows PowerShell" "powershell -NoExit venv\Scripts\activate" ``` [source](https://superuser.com/questions/1831565/windows-terminal-open-cmd-exe-then-run-script)
Author
Owner

@Stephenremmi commented on GitHub (Apr 12, 2024):

Ensure pip and python is installed i.e pip -V and python --version respectively
For python3: python3 -m virtualenv venv.
Then, in your bash run, this command: source venv/Scripts/activate.
To confirm it works venv will be added to the root directory and perfoming source venv/Scripts/activate command will add (venv) to the bash current path.

@Stephenremmi commented on GitHub (Apr 12, 2024): Ensure pip and python is installed i.e pip -V and python --version respectively For python3: python3 -m virtualenv venv. Then, in your bash run, this command: source venv/Scripts/activate. To confirm it works venv will be added to the root directory and perfoming source venv/Scripts/activate command will add (venv) to the bash current path.
Author
Owner

@balajishiva2001 commented on GitHub (Jul 25, 2024):

To Resolve issue:
For Windows (Specifically VSCode): Here, the VSCode terminal is nothing but PowerShell.

Step 1: Invoke the below command first
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

Step 2: Then invoke our command , here venv is the environment name.
.\venv\Scripts\Activate.ps1

Screenshot 2024-07-25 210743

@balajishiva2001 commented on GitHub (Jul 25, 2024): **To Resolve issue:** **For Windows (Specifically VSCode):** Here, the VSCode terminal is nothing but PowerShell. Step 1: Invoke the below command first `Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted` Step 2: Then invoke our command , here venv is the environment name. `.\venv\Scripts\Activate.ps1` ![Screenshot 2024-07-25 210743](https://github.com/user-attachments/assets/8cab107c-c628-4b13-8fed-39810d6fc4c6)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17859