question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PowerShell does not support automatic activation of conda virtual environment

See original GitHub issue

It seems that the powershell terminal does not support automatic activation of the conda virtual environment?I am not sure if this is my problem or it is currently the case.

If we need a way to activate the conda virtual environment from the powershell terminal, I hope the following information can provide some help

Anaconda supports powershell terminal.The following is an example of the startup command provided by Anaconda:

%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'F:\ProgramData\Anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'F:\ProgramData\Anaconda3' "

According to the above information, I activated the conda virtual environment in the powershell terminal of VSCode

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jamespreedcommented, Feb 18, 2022

For those having issues getting PowerShell to drop into a conda environment correctly, the following settings work by calling the proper conda scripts when PowerShell launches. You will need to modify the paths to point to your condabin folder.

    "python.condaPath": "C:\\Anaconda3\\condabin\\conda.bat",
    "terminal.integrated.defaultProfile.windows": "PowerShell",

    "terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
            "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",  // using powershell 7
            "icon": "terminal-powershell",
            "args": [
                "-ExecutionPolicy", 
                "ByPass", 
                "-NoLogo",
                "-NoExit",
                "-Command",
                "& 'C:\\Anaconda3\\condabin\\conda_hook.bat'; conda init powershell | Out-Null"  // direct to null, conda init is noisy
            ]
        }
2reactions
karthiknadigcommented, May 11, 2020

@alexzshl Our recommendation for now is to activate conda first and then start code using code . in your workspace/project folder. https://github.com/microsoft/vscode-python/issues/10626

Read more comments on GitHub >

github_iconTop Results From Across the Web

Conda environment is not activated in Powershell on ...
Start new project in PyCharm with a new Conda environment. Make sure "Activate virtualenv" is enabled in the Terminal settings.
Read more >
Automatically activate conda evironment in Powershell for ...
This shell to conda integration is done by the vscode python integration. Github source. The problem. But there is one problem. I don't...
Read more >
How to activate conda environment from powershell?
Open Powershell and browse to condabin folder in your conda installation directory, for example: C:\Users\<username>\anaconda3\condabin · Run ./ ...
Read more >
Windows error: "activate.ps1 cannot be loaded because ...
Option 3 - Disable automatic activation of Python environments. If you want to use PowerShell in VS Code, but don't want to relax...
Read more >
Virtual Environments
RStudio will automatically activate any venv or condaenv that it finds within a project directory. Just be sure to create an RStudio project...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found