You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extension version (available under the Extensions sidebar): 2019.1.0
OS and version: Windows 10
Python version (& distribution if applicable, e.g. Anaconda): Miniconda 3.6.6 64-bit ('py36': conda)
Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
Relevant/affected Python packages and their versions:
Expected behaviour
VSC opens interactive python using active py36 environment
Actual behaviour
VSC is open with active ('py36': conda) environment
Python: Show Python Interactive window
Error message: Jupyter kernel cannot be started from 'Python 3.6.6 64-bit ('py36': conda)'. Using closest match Python 3.6.6 64-bit ('mro': conda) instead.
Steps to reproduce:
Open VSC in empty directory
Python: Select Interpreter
select 'py36'
Python: Show Python Interactive window
Logs
Relevant Part from Developer Tools > Console Log:
Python Extension: Python Extension (Error in getActivatedEnvironmentVariables, method:getActivatedEnvironmentVariables):
Error: Command failed:
C:/Users/marek.ozana.XCF/AppData/Local/Continuum/miniconda3/envs/py36/Scripts/activate && conda activate py36 && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python C:/Users/marek.ozana.XCF/.vscode/extensions/ms-python.python-2019.1.0/pythonFiles/printEnvVariables.py
Could not find conda environment: py36
You can list all discoverable environments with `conda info --envs`.
at ChildProcess.exithandler (child_process.js:303:12)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:961:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
t.log @ console.ts:134
The problem seems to be that process is already in 'py36' environment and thus fails when trying to activate py36 again: C:/Users/marek.ozana.XCF/AppData/Local/Continuum/miniconda3/envs/py36/Scripts/activate && conda activate py36
I re-installed the Don's extension "Jupyter 1.1.4" and it nicely opens Jupyter notebook in the correct environment. So the issue is only with the new interactive python.
Jupyter Notebook log:
Starting Jupyter Notebook
jupyter notebook --no-browser --port=8888 --NotebookApp.allow_origin="*"
[I 10:24:22.506 NotebookApp] [nb_conda_kernels] enabled, 3 kernels found
[I 10:24:23.050 NotebookApp] The port 8888 is already in use, trying another port.
[I 10:24:23.051 NotebookApp] The port 8889 is already in use, trying another port.
[I 10:24:23.158 NotebookApp] [jupyter_nbextensions_configurator] enabled 0.4.1
[I 10:24:23.245 NotebookApp] JupyterLab extension loaded from C:\Users\marek.ozana.XCF\AppData\Local\Continuum\miniconda3\envs\py36\lib\site-packages\jupyterlab
[I 10:24:23.245 NotebookApp] JupyterLab application directory is C:\Users\marek.ozana.XCF\AppData\Local\Continuum\miniconda3\envs\py36\share\jupyter\lab
[I 10:24:23.257 NotebookApp] [nb_conda] enabled
[I 10:24:23.258 NotebookApp] Serving notebooks from local directory: d:\Projects\Python\Misc\BUG
[I 10:24:23.258 NotebookApp] The Jupyter Notebook is running at:
[I 10:24:23.258 NotebookApp] http://localhost:8890/?token=148d5e58990e52b07a6557afcc389e81a240e95a14d83f22
[I 10:24:23.258 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 10:24:23.271 NotebookApp]
To access the notebook, open this file in a browser:
file:///C:/Users/marek.ozana.XCF/AppData/Roaming/jupyter/runtime/nbserver-22232-open.html
Or copy and paste one of these URLs:
http://localhost:8890/?token=148d5e58990e52b07a6557afcc389e81a240e95a14d83f22
[I 10:24:25.815 NotebookApp] Kernel started: 08fa9738-4a01-4d45-9f57-6bf66ce9ba70
[I 10:24:27.038 NotebookApp] Adapting to protocol v5.1 for kernel 08fa9738-4a01-4d45-9f57-6bf66ce9ba70
I noticed that Python: Create Terminal has the same issue with incorrect environment:
Microsoft Windows [Version 10.0.17763.316]
(c) 2018 Microsoft Corporation. All rights reserved.
D:\Projects\Python\EcoCharts\MarketUpdate>C:/Users/marek.ozana.XCF/AppData/Local/Continuum/miniconda3/envs/py36/Scripts/activate
(base) D:\Projects\Python\EcoCharts\MarketUpdate>conda activate py36
Could not find conda environment: py36
You can list all discoverable environments with `conda info --envs`.
It tries to activate 'py36' environment while already being in it. When listing environments I get:
(base) D:\Projects\Python\EcoCharts\MarketUpdate>conda info --envs
# conda environments:
#
C:\Users\marek.ozana.XCF\AppData\Local\Continuum\miniconda3
C:\Users\marek.ozana.XCF\AppData\Local\Continuum\miniconda3\envs\keras
C:\Users\marek.ozana.XCF\AppData\Local\Continuum\miniconda3\envs\mro
base * C:\Users\marek.ozana.XCF\AppData\Local\Continuum\miniconda3\envs\py36
C:\Users\marek.ozana.XCF\AppData\Local\Continuum\miniconda3\envs\py37
So in summary VSC is in 'py36' environment but incorrectly calles it 'base'.
However in this case the issue is not fatal since 'py36' is activated so one can continue working. In case of jupyter one cannot start 'py36'....
I am not sure if you experience the same issue. I get this issue only on Windows.
In summary:
create conda environment py36
select py36 in VSCode
creation of python terminal (or interactive python) fails because py36 environment cannot be activated inside of py36 environment.
On Windows I get this error (mind that it incorrectly uses ../envs/py36/../activate and not base activate):
.../Continuum/miniconda3/envs/py36/Scripts/activate
(base) C:\Test>conda activate py36
Could not find conda environment: py36
You can list all discoverable environments with `conda info --envs`
On Linux the activation correctly uses the base conda envirnment and works nicely:
I tried on several different Windows computers using clean miniconda install and I am getting allways teh same issue. It stops me from using interactive python on Windows. The only workaround right now is to use the deprecated Don's jupyter extension, but unfortunately this does not work with python 3.7.
Thank you for your time and help fixing this bug.
Sorry I must be missing something. That line of code is just looking in the Scripts folder for the conda executable next to the python that was found. Why is this causing a problem?
The way this stuff was supposed to work was we call conda activate for the base and then inside the base, call the conda activate 'env-name'. It looks like we don't find the base. I'm guessing we're using the python.exe path and assuming it's for the 'base' and that there isn't one for the sub environment.
For example, here's what happens on my own machine:
root@e1176206961b:/home# source /opt/conda/envs/test-issue/bin/activate
(base) root@e1176206961b:/home# conda activate test-issue
Could not find conda environment: test-issue
You can list all discoverable environments with `conda info --envs`.
(base) root@e1176206961b:/home#
Removing the code lines I mentioned earlier resolves the problem.
It is not normal but still happening from time to time. You can use conda programmatically to inspect your environment and also use this to build packages.
In the case of conda environments, I would never call the activate scripts but only ever call the default location. activate should only be called in virtualenv situations. The above linked code is though only executed when we're already sure that we're dealing with a conda environment.
Is it normal to install conda in a test environment? Is that so you can have a different conda?
Now-a-days, conda is only ever installed in the base env. We don't even put hooks to it into other envs anymore. Instead, the base env's condabin directory remains on PATH always.
Is it normal to install conda in a test environment? Is that so you can have a different conda?
Now-a-days, conda is only ever installed in the base env. We don't even put hooks to it into other envs anymore. Instead, the base env's condabin directory remains on PATH always.
Maybe to add my usecase why I have conda installed in a conda environment itself: I have code that uses conda itself to get information about an environment and also creates a set of environments out of this environment.
The bug happens when I install conda-build package (used to build and develop packages locally) inside an environment.
The steps are describe in my post above: #4402 (comment)
Activity
MarekOzana commentedon Feb 14, 2019
I re-installed the Don's extension "Jupyter 1.1.4" and it nicely opens Jupyter notebook in the correct environment. So the issue is only with the new interactive python.
Jupyter Notebook log:
MarekOzana commentedon Feb 14, 2019
I noticed that
Python: Create Terminalhas the same issue with incorrect environment:It tries to activate 'py36' environment while already being in it. When listing environments I get:
So in summary VSC is in 'py36' environment but incorrectly calles it 'base'.
However in this case the issue is not fatal since 'py36' is activated so one can continue working. In case of jupyter one cannot start 'py36'....
[-]interactive python opens incorrect environment[/-][+]Conda activation is failing[/+]ronglums commentedon Feb 15, 2019
Not data science specific. also happened in the terminal window.
benlindsay commentedon Feb 18, 2019
MarekOzana commentedon Feb 18, 2019
I am not sure if you experience the same issue. I get this issue only on Windows.
In summary:
On Windows I get this error (mind that it incorrectly uses ../envs/py36/../activate and not base activate):
On Linux the activation correctly uses the base conda envirnment and works nicely:
I tried on several different Windows computers using clean miniconda install and I am getting allways teh same issue. It stops me from using interactive python on Windows. The only workaround right now is to use the deprecated Don's jupyter extension, but unfortunately this does not work with python 3.7.
Thank you for your time and help fixing this bug.
benlindsay commentedon Feb 18, 2019
27 remaining items
rchiodo commentedon Apr 29, 2019
Sorry I must be missing something. That line of code is just looking in the Scripts folder for the conda executable next to the python that was found. Why is this causing a problem?
The way this stuff was supposed to work was we call conda activate for the base and then inside the base, call the conda activate 'env-name'. It looks like we don't find the base. I'm guessing we're using the python.exe path and assuming it's for the 'base' and that there isn't one for the sub environment.
For example, here's what happens on my own machine:
C:/Users/rchiodo/AppData/Local/Continuum/anaconda3/Scripts/activate is where the base conda was installed. It's next to where the python.exe is found.
The 'jupyter' environment is the secondary environment it's activating.
It looks like for MarekOzana, the first activate is the wrong one. We must be using the python installed in the environment instead.
xhochy commentedon Apr 29, 2019
Rich Chiodo (@rchiodo) The problem is only occuring when you have
condainstalled in the non-base environment.The following steps show the issue:
test-issuetest-issueas the interpreter and open a terminal:condain the test-envRemoving the code lines I mentioned earlier resolves the problem.
rchiodo commentedon Apr 29, 2019
Ah that's because it doesn't find an activate so falls back to the default location.
Is it normal to install conda in a test environment? Is that so you can have a different conda?
xhochy commentedon Apr 29, 2019
It is not normal but still happening from time to time. You can use
condaprogrammatically to inspect your environment and also use this to build packages.In the case of conda environments, I would never call the
activatescripts but only ever call the default location.activateshould only be called invirtualenvsituations. The above linked code is though only executed when we're already sure that we're dealing with a conda environment.Don't use activate from inside conda environments
Don't use activate from inside conda environments
Don't use activate from inside conda environments
Don't use activate from inside conda environments (#5516)
mingwandroid commentedon May 20, 2019
Now-a-days, conda is only ever installed in the
baseenv. We don't even put hooks to it into other envs anymore. Instead, the base env's condabin directory remains on PATH always.xhochy commentedon May 21, 2019
Maybe to add my usecase why I have
condainstalled in acondaenvironment itself: I have code that uses conda itself to get information about an environment and also creates a set of environments out of this environment.mingwandroid commentedon May 21, 2019
How have you done this? Conda prevents it!
MarekOzana commentedon May 21, 2019
The bug happens when I install conda-build package (used to build and develop packages locally) inside an environment.
The steps are describe in my post above:
#4402 (comment)
conda create -n bug_env python jupyter conda-buildxhochy commentedon May 21, 2019
Just like with any other package:
Also it should not prevent it as I want to use the Python API of the package: https://docs.conda.io/projects/conda/en/latest/api/