Support discovering multiple conda envs with same interpreter path #18357
Copy link
Copy link
Closed
Labels
area-environmentsFeatures relating to handling interpreter environmentsFeatures relating to handling interpreter environmentsfeature-requestRequest for new features or functionalityRequest for new features or functionalityon-testplanAdded to test planAdded to test planpartner ask
Milestone
Description
Testing #18348
- Install conda
- Create two conda environments like so:
conda create -n test1
conda create -n test2 - Activate each and get python path. They should be the same
- Try using the API to find them.
They don't show up at all.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-environmentsFeatures relating to handling interpreter environmentsFeatures relating to handling interpreter environmentsfeature-requestRequest for new features or functionalityRequest for new features or functionalityon-testplanAdded to test planAdded to test planpartner ask
Activity
karthiknadig commentedon Jan 25, 2022
Rich Chiodo (@rchiodo) Which API did you use? if the extension was already loaded and you created these then you may have to call
refreshInterpreterswith clear cache./cc Kartik Raj (@karrtikr) This seems like a underlying discovery issue.
karthiknadig commentedon Jan 25, 2022
Rich Chiodo (@rchiodo)
conda create -n test1does not create a conda environment with python in it.. you have to doconda create -n test1 pythonas you can see in my case there is no global python, so when i ask for python path after activation i get nothing:

but if you create conda environment with python then you get python path:

rchiodo commentedon Jan 25, 2022
I guess I have a global python set. I didn't get that error
rchiodo commentedon Jan 25, 2022
Here's what I used to test:
https://github.com/rchiodo/test-python-api
karthiknadig commentedon Jan 25, 2022
So if the environment itself does not have python, then we don't detect it or report anything about it. does this happen if you create it like this:
This is 3.9 because 3.10 in conda is broken.
rchiodo commentedon Jan 25, 2022
No that works fine. That's usually how I have to create them in order to get them to work.
rchiodo commentedon Jan 25, 2022
I mean this is a problem in the old API too.
karthiknadig commentedon Jan 25, 2022
Then this is working as expected. if the environment was not created to include python we don't detect those.
rchiodo commentedon Jan 25, 2022
I don't think a customer is going to expect this. They have multiple conda environments but they don't see any of them.
karthiknadig commentedon Jan 25, 2022
You can have pure R environments in conda. Do we expect python extension to detect those? The python in environment created using
conda create -n env1is not the python from the environment. So, if we say install things in the python, then it would be the global python. Essentially, all installation will happen to that. I think that this might lead to greater problems with the python on the machine itself./cc Brett Cannon (@brettcannon), Luciana Abud (@luabud) what do you suggest, should we list every conda environment or only those envs that have been setup with python. Currently we only detect those that have python in the env scripts/bin folder.
rchiodo commentedon Jan 25, 2022
This isn't true. If I do something like so:
It installs it here (even though python is global):
If I run python from that active environment, its sys path has been modified to use the conda location, and not the global:
Conda supports this option just fine.
27 remaining items
greazer commentedon Jan 27, 2022
I just ran into this myself by accident.
Everything seems fine, except I cannot find the environment in VS Code no matter what I do. Of course if I examine my environments with conda, I see it too. This is all highly confusing.
I'm not sure I believe that this was never supported since most of the environments I've ever created I have used anaconda and I haven't specified a python version instance to install to it. In fact, the only reason I ever thought to do that was in case I wanted to use a different version of python than is available on the system. Perhaps I'm incorrect in that thinking, but it seems to make sense.
Also note if I do an internet search for "How do I create a new conda environment" the first link I get is this:
https://towardsdatascience.com/manage-data-science-and-machine-learning-environments-using-conda-42b9b2f0689a#:~:text=1%20Creating%20a%20New%20Conda%20Environment.%20You%20will,specify%20the%20version%20at%20the%20time%20of%20
It basically says what I just said above. :)
brettcannon commentedon Jan 27, 2022
Jim Griesmer (@greazer) it's never been supported by us; see https://code.visualstudio.com/docs/python/environments#_where-the-extension-looks-for-environments and point 7:
conda itself may be manifesting the interpreter lazily upon
conda installor something.