-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Comments
Hey @gb119, thanks for reporting. You said:
Do you have several Anaconda/Miniconda/Miniforge installations in your system? Maybe in one of them
Well, the "is in conda env" check is very simple (just verifying that a directory exists) and it runs before calling
Yep, I know. However, I saw that you have the
Good catch! I'll submit a PR to fix it.
What do you mean by this? Is your |
Hey @gb119, any follow-up about my questions above? Otherwise, I'm afraid I'll have to close this issue. |
Sorry - end of academic term means I get a bit sidetracked!
Yes, I've got a very ancient Miniconda as well as a current Anaconda. I need the ancient miniconda becuse of other projects that require a Python 3.6 dll that is compiled with particular VS C++ version (!). However, the intermittent nature of this problem seems to be not straightforwardly that I pick up the ancient conda.
I;ll take a look once I've got 6.0.3 installed and fixed my version to deal with the known issue with the Projects plugin widget and remote drives. Hope to spend asome time with this this weekend.
I've had this disabled and I still get the problem periodically. It's very irritating because it is intermittent! |
So a bit of further investigation ow I know where to look. I think I'm just a very weird corner case because I have an ancient conda at the end of my PATH. It seems that under some circumstances (and this is the bit I don't understand yet), Spyder is getting launched without CONDA_EXE being set in the environment variables and then in The workaround that should work consistently is to manually make sure I have CONDA_EXE set in my environment variables, but I still don't understand why it is an intermittent error and most of the time it will start fine and then sometimes it falls over. I also wonder whether it would be sensible to do a version check on conda before assuming that conda run will work - that at least would give a less confusing failure. If you want to close this issue, then fine I'll accept I'm just a rogue data point - the main (new) reason for this issue was the problem with spyder_conda_channel() that you've already fixed. |
Actually, before closing this one - there's another bad code smell....
Probably a bad idea to pass a mutable empty list as the default value of a keyword argument. Shouldn't this be: (...and just spotted also in Finally in I don't know if this is why I'm getting inconsistencies, but I could believe a race condition with default arguments getting mutated when accessing project files off very slow file systems might do the trick. |
Ok, just done a |
This was reported in #22554 and we'll try to fix it in one of the coming 6.0.x releases.
Yeah, I think that's a good idea. @mrclary, could you take a look at that?
Thanks for your help with that! I agree it's a good idea to fix those cases. |
So a few questions.
Can you tell me what is the conda version in your ancient miniconda installation? Nevertheless, I'm interested in the intermittent nature of the problem because, even with the I agree that we can move the |
I'll need to confirm this when I back in front of the right computer - but it could well be older than 4.6.x! (to explain, I'm also maintaining a large NI LabVIEW 2018 codebase - that links to a Python 3.6.5 dll and is limited to the versions it will accept, can't cope without the dll being in the PATH and that codebase also needs a few other packages installed! Legacy code fun...).
So I think it is correlated to, but not deterministically, to having spyder projects on network drives that are either very slow or sometimes missing. From the poking I've done and somewhat limited understanding of how spyder works, it seemed to me that with some of the functions used in locating conda taking default arguments that were mutable, it would be possible that in the process of loading a project from a slow network drive there might be a race condition that sometime resulted in the default argument being mutated in such a way as to locate a conda in the path before locating conda in the environment from which Spyder is running. I think my setup is some really weird corner case, but perhaps it is serving to show that the conda location is not quite as robust as it could be....
|
Okay, I found the problem. The relevant code is here: spyder/spyder/utils/programs.py Line 115 in 3f64ee3
The problem is the use of @gb119, how are you launching Spyder? If you can explicitly set the |
Ah, sorry didn't realise you didn't know where I was looking - there's already a pull request from me to remove the default mutable arguments from that function (and a bunch of others). Guess it just needs: Although in practice set() seems often to preserve item order in modern cpython.
I have now put CONDA_EXE explicitly int he system environment variables having crawled over that bit of code (it wasn't there as a side effect of the weirdness of keeping the ancient miniconda in PATH and the modern anaconda3 out of it. |
Technically, the mutable argument is unrelated to this issue.
This will result in pyenv + conda + extra_paths + system paths, not extra_paths + conda + pyenv + system paths. |
So sometimes when starting Spyder (with or without the edits to the projects widget), the Ipython shell comes up looking like this:
, but if I simply restart Spyder then it comes up as I would expect:
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....
The text was updated successfully, but these errors were encountered: