-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Python conda run incorrect environment path #18493
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
Comments
+1, also seeing the same error. Extension version: |
That is an issue with conda itself. Previous versions of the extension were using a hack. That hack no longer works starting conda 4.10. we decided to use the |
Are you sure about this? When I run the exact same command as vscode in a terminal, the command runs just fine. That leads me to believe this is some kind of error in the extension's shell environment setup.
|
Is there a difference between the environment variables in the VS Code terminal VS the external terminal? What happens if you activate the environment in a terminal and then run the above command? The reason I believe this is a related mamba-org/mamba#1467 |
Thanks for thinking about this! Here, I'm running the exact test discovery command first from the internal VSCode terminal, both with the base environment activated and then with the relevant environment activated. And then, in the second block, I run both commands again from an external terminal (mac, kitty, zsh). In both situations, the commands run without error. Whereas when run from the pytest test discovery tool, the command fails with the error from the original issue post. This is why I lean towards thinking there's something wrong in the test discovery conda call. My only theory is that perhaps the test discovery is running in a different shell and hasn't had the shell code that gets added by VSCode built-in terminal:
External terminal:
pytest test discovery:
|
Ok, this is solved for me. The only thing I changed is that I cleared the |
@tbenthompson This is strange, and thanks for digging into it. Can you share what you had for |
I had Also, this is hilarious. I tried setting |
@tbenthompson Can you tell me what you have for this setting? |
It is unchecked. If I check it doesn't change any of the previously discussed behavior. |
This might not be directly related, but I am able to trigger the same error as @tbenthompson in the pytest test discovery if both the following conditions are met:
Steps to reproduce:
Some notes:
Perhaps this is a known issue? It seems to be mentioned here: https://devblogs.microsoft.com/python/python-in-visual-studio-code-february-2022-release/#improvements-when-using-anaconda Edit: I am running ubuntu 20.04 on WSL2 if that matters for "special characters in file paths" as mentioned in the blog. |
@cswartzvi Thanks for the super useful info and explanation. I just checked and you are absolutely right that I have the conda package installed in all the environments that are causing the issue. Uninstalling conda from an env solves the issues. Now that I think about the symptoms it seems obvious that this is the problem! While this is probably user error, it seems like a type of user error that the VSCode could easily either correct for or yell about. |
@cswartzvi @tbenthompson Thanks for the investigation and patience. We will discuss this internally and update on this. |
this is the conda issue: it seems pretty serious from the point of view of using |
Just wanted to update the thread that I've run into this problem again. After I remembered that I'd dealt with it a few weeks ago, I was able to solve it the same way again: uninstall conda from the environment. This is a bit unfortunate and annoying because there are common use cases and real benefits to having conda installed in an environment. |
I'm setting up VSCode on a new computer and I think I am having a similar problem with pytest test discovery. I'm developing a package in a Conda environment called Version: 1.66.0 (user setup) Here is the output from the discovery:
|
Looks like this is addressed in The fix is available in the canary version of conda.
We plan on continuing with |
Hi guys, @karthiknadig, I tried this solution but it didn't work for me. What ended up solving it, was to perform the installation of an earlier version of the ms-python package, it being version v2022.2.1924087327. But even so, I still can't run any more tests with plugin Test Explorer UI only in terminal by command line,now with the previous version package for ms-python I can run only the debug mode. Because of this, I created a new issue, related to this, for a newer version to try to understand the problem! First of all, I use vscode on linux, in the version described in the issue. |
Created a bug on conda: conda/conda#12082, feel free to upvote that to raise priority. Closing in favor of conda. |
Behaviour
I get the following error when running pytest test discovery. It looked like the environment path is getting duplicated:
envs/kevlar/envs/kevlar
. I'm on the latest conda 4.11 and fully updated to the latest VSCode version. I've seen #18486 and this seems related but the updates and solutions there have done nothing for me. I've also recreated the environment to see if a brand new environment would avoid this error.Expected vs. Actual
XXX
Steps to reproduce:
Diagnostic data
python.languageServer
setting: DefaultUser Settings
The text was updated successfully, but these errors were encountered: