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

conda environment activation not working in Python Terminal #18716

Closed
danielsc opened this issue Mar 18, 2022 · 3 comments
Closed

conda environment activation not working in Python Terminal #18716

danielsc opened this issue Mar 18, 2022 · 3 comments
Assignees
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster investigating We are looking into the cause of the issue

Comments

@danielsc
Copy link

We have written the neede
Issue Type: Bug

Behaviour

Expected vs. Actual

I am using conda environments in vscode on a mac (with apple silicon -- but that probably doesn't matter).
I set my python interpreter to the right conda environment, but in the Terminal that environment is not activated, instead the default system python continues to be used.

Steps to reproduce:

  1. Create a conda environment
    conda create --name test python=3.10
  2. Python: Select Interpreter, setting it to the conda environment
    MicrosoftTeams-image
  3. Python: Create Terminal.
    VSCode is executing the right conda command to activate the environment:
    MicrosoftTeams-image (1)
    but somehow it messes up and the path still has the global python ahead of the conda env's python:
    MicrosoftTeams-image (2)
  4. run: which python to see that the system python is used
  5. run: echo $PATH to see that /usr/bin is before /Users/danielsc/opt/miniconda3/envs/vnext/bin or whatever your conda envs location is
  6. Do the same in a system shell to see that it works fine there:
    MicrosoftTeams-image (3)

When running tests or a .py file, it seems to now be using conda run, so everything works fine there:

(test) danielsc@Daniels-MacBook-Pro vnext % conda run -n test --no-capture-output --live-stream python /Users/danielsc/git/vnext/processing/process_md_for_includes.py

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.7.12
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Default
User Settings


defaultLS: {
    "defaultLSType": "Pylance"
}

downloadLanguageServer: true

envFile: "<placeholder>"

venvPath: "<placeholder>"

venvFolders: "<placeholder>"

condaPath: "<placeholder>"

pipenvPath: "<placeholder>"

poetryPath: "<placeholder>"

languageServer: "Pylance"

linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: false
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: false
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: true
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"

sortImports
• args: "<placeholder>"
• path: "<placeholder>"

formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "autopep8"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"

testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: false
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: false
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: true
• autoTestDiscoverOnSaveEnabled: true

terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"

experiments
• enabled: true
• optInto: []
• optOutFrom: []

insidersChannel: "off"

tensorBoard
• logDirectory: "<placeholder>"

Extension version: 2022.2.1924087327
VS Code version: Code 1.65.2 (Universal) (c722ca6c7eed3d7987c0d5c3df5c45f6b15e77d1, 2022-03-10T14:33:49.188Z)
OS version: Darwin arm64 21.3.0
Restricted Mode: No

System Info
Item Value
CPUs Apple M1 Pro (10 x 24)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: disabled_off_ok
video_decode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 2, 4, 4
Memory (System) 16.00GB (0.09GB free)
Process Argv --crash-reporter-id 71c792d0-e169-43f5-83f8-d8cde4befb10
Screen Reader no
VM 0%
A/B Experiments
vsliv368:30146709
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30294714
vstes263cf:30335440
vscorecescf:30445987
pythondataviewer:30285071
vscod805:30301674
pythonvspyt200:30340761
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vsclayoutctrt:30451275
dsvsc009:30452663
pythonvspyt640:30450904
vscscmwlcmc:30438804
dockersurvey3:30453609
pynewfile477:30450038

d data into your clipboard because it was too large to send. Please paste.
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Mar 18, 2022
@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug area-terminal triage and removed triage-needed Needs assignment to the proper sub-team labels Mar 21, 2022
@karrtikr karrtikr added investigating We are looking into the cause of the issue and removed triage labels Mar 21, 2022
@karrtikr
Copy link

karrtikr commented Apr 7, 2022

This is a known issue in VS Code and we're in the process of resolving this.
More info can be found here https://code.visualstudio.com/updates/v1_36#_launch-terminals-with-clean-environments

As a temporary solution please change the setting terminal.integrated.inheritEnv to false as outlined in https://code.visualstudio.com/updates/v1_36#_launch-terminals-with-clean-environments

Please let us know how this goes.

@karrtikr karrtikr added the info-needed Issue requires more information from poster label Apr 7, 2022
@karrtikr
Copy link

karrtikr commented Apr 7, 2022

Another alternative is to make sure VS Code is running in a activated environment. Try this:

  1. Anaconda prompt and cd to your workspace.
  2. Activate the environment using conda activate
  3. Start VS Code using code .

related #10626

@brettcannon
Copy link
Member

Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-terminal bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster investigating We are looking into the cause of the issue
Projects
None yet
Development

No branches or pull requests

4 participants