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

Internal Error in util/conda.py if conda channel not found #23061

Open
gb119 opened this issue Nov 23, 2024 · 1 comment
Open

Internal Error in util/conda.py if conda channel not found #23061

gb119 opened this issue Nov 23, 2024 · 1 comment

Comments

@gb119
Copy link

gb119 commented Nov 23, 2024

I was still having persistent problems with it thinking conda run wasn't a command though - is there a point where it does a test for installed conda that might be timing out on me? It stops the Ipython console from working.

I don't understand this comment very well. Is the IPython console not working for you? Or are you getting an error similar to the one reported in #22554?

So sometimes when starting Spyder (with or without the edits to the projects widget), the Ipython shell comes up looking like this:
image
, but if I simply restart Spyder then it comes up as I would expect:
image
When it is in the error condition then restarting just the console or unloading and loading projects does not fix the issue and it always comes back saying that there is no command "conda run". Needless to say there is a "conda run" in the environment and most of the time spyder seems to find it ok! I've tried start spyder from the command line with the debugging output on but I can't (easily) see where it decides that conda run doesn't exist.
From the "sticky" nature of the problem and the fact it is intermittent (and not predictable as far as I can tell) makes me think that there must be a race condition or a timeout or similar at the point where spyder is deciding it is working in a conda environment - but I've not looked at the code enough to know where to look and what to look for. Sorry, that's not the most useful bug report!

Originally posted by @gb119 in #22556 (comment)

By chance I noticed that after I had this problem I sometimes got the internal error dialog box and spotted that in utils/conda.py in get_spyder_conda_channel() there is a possible condition in which you index None. The test in line 196 needs to check first that channel_url is not None before looking for "<develop>".
I have no idea if this is actually the cause of my problem (it seems to involve network paths not being consistently present), but it's definitely not right....

@ccordoba12
Copy link
Member

ccordoba12 commented Nov 24, 2024

Hey @gb119, thanks for reporting. You said:

Needless to say there is a "conda run" in the environment and most of the time spyder seems to find it ok!

Do you have several Anaconda/Miniconda/Miniforge installations in your system? Maybe in one of them conda is too old and doesn't support the conda run command. And sometimes Spyder is using it.

I've tried start spyder from the command line with the debugging output on but I can't (easily) see where it decides that conda run doesn't exist.

conda run is executed automatically when starting a new console (when we detect the interpreter is in a conda env), so that error is reported automatically by conda, not by Spyder.

From the "sticky" nature of the problem and the fact it is intermittent (and not predictable as far as I can tell) makes me think that there must be a race condition or a timeout or similar at the point where spyder is deciding it is working in a conda environment - but I've not looked at the code enough to know where to look and what to look for.

Well, the "is in conda env" check is very simple (just verifying that a directory exists) and it runs before calling conda run. The logic is in spyder/plugins/ipythonconsole/utils/kernelspec.py, in case you want to check it.

Sorry, that's not the most useful bug report!

Yep, I know. However, I saw that you have the Automatically load Numpy and Matplotlib modules enabled. Just to be sure, please disable it (along with any other custom option for the IPython console you have, one by one) and see if you can reproduce the problem. Maybe one of those options is interfering with our conda detection mechanism somehow.

By chance I noticed that after I had this problem I sometimes got the internal error dialog box and spotted that in utils/conda.py in get_spyder_conda_channel() there is a possible condition in which you index None. The test in line 196 needs to check first that channel_url is not None before looking for "".

Good catch! I'll submit a PR to fix it.

I have no idea if this is actually the cause of my problem (it seems to involve network paths not being consistently present), but it's definitely not right....

What do you mean by this? Is your conda command placed in a network drive? Or perhaps your environments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants