Python: Create Terminal Doesn't Use Activate.ps1 in Powershell
See original GitHub issueEnvironment data
- VS Code version: 1.37
- Extension version (available under the Extensions sidebar): 2019.8.29288
- OS and version: Windows 10 1903
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.7.3 64-bit
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): venv
- Relevant/affected Python packages and their versions: N/A
- Jedi or Language Server? (i.e. what is
"python.jediEnabled"
set to; more info #3977): Jedi
Expected behaviour
Running the Python: Create Terminal
command should properly activate my terminal using Activate.ps1
I expect to see this
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
Loading personal and system profiles took 1881ms.
D:\MyProject [master ≡ +1 ~7 -0 !]> d:/MyProject/venv/Scripts/Activate.ps1
D:\MyProject [master ≡ +1 ~7 -0 !]>
Actual behaviour
The command activates my terminal with activate.bat
This is what I see
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.
Try the new cross-platform PowerShell https://aka.ms/pscore6
Loading personal and system profiles took 1881ms.
D:\MyProject [master ≡ +1 ~7 -0 !]> d:/MyProject/venv/Scripts/activate.bat
D:\MyProject [master ≡ +1 ~7 -0 !]>
Steps to reproduce:
- Run the
Python: Create Terminal
command.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:10
Top Results From Across the Web
VS code terminal : Activate.ps1 cannot be loaded because ...
A way is changing the terminal in VSCode to Command Prompt instead of PowerShell. Open the drop-down on the right of the terminal...
Read more >PowerShell prompt doesn't show virtualenv : PY-22469
There's a workaround for this issue. Under Settings > Tools > Terminal you can uncheck the Activate virtualenv option and then set the...
Read more >Windows error: "activate.ps1 cannot be loaded because ...
This newly created VS Code Terminal will be using Command Prompt (similar to what you would see if you opened a Command Prompt...
Read more >Cannot activate - Python - The freeCodeCamp Forum
I created a virtualenv for python, and I am trying to activate it with ... On Windows using PowerShell: path\to\venv\Scripts\Activate.ps1.
Read more >Terminal Shell Integration in Visual Studio Code
By default, the shell integration script should automatically activate on supported shells launched from VS Code. This is done by injecting arguments and/or ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello! I did some digging tonight with the code pulled from github. The issue seems to be related to the
shellDetector
that works based on the name of the terminal. If it doesn’t have a match, it returns the value “other”, which is then considered a success on line 57 of the same file.By changing the test condition from
if (shell) {
toif (shell && shell !== 'other') {
, the detection is considered failed and the next detectors can be used. It leads to a correct detection of the shell type, therefore the correct “activate” script is used.I don’t know if the test condition in the
identifyTerminalShell
needs to be modified, or if it’s the shell detector itself that should returnundefined
instead of the value “other”…Anyways, I hope this helps! I would make a pull request but my modification actually breaks two unit tests: Interpreters Known Paths Ensure known list of paths are returned on non-windows Ensure PATH variable and known list of paths are merged on non-windows
Thanks for the help!
Hi! I confirm I have the same issue, but with small differences in the environment: Environment data
It affects Powershell Core 6 as well as Powershell. One possible workaround is to switch default shell to
cmd
, but I prefer the flexibility of Powershell. The other option is to stay on version 2019.6.24221, which is not affected by this bug.