EDIT: Problem solved.
Turns out Avast was classifying python.exe within the environments as a virus due to fresh conda installs (and being in silent mode I never found out). Solution found from here: https://github.com/ContinuumIO/anaconda-issues/issues/8266
__
I have something of a problem which I haven't seen anyone else directly have with conda environments and python kernels.
I can successfully create environments and install packages in them etc., but everytime I try to either (i) start a jupyter notebook or (ii) otherwise call an environment kernel in e.g. the VS Code jupyter extension, the kernel environment kernel "disappears" entirely from the environment in question.
In the former jupyter case, the environment successfully launches the notebook browser window when calling "jupyter-notebook" for the first time, but after some 5-10 seconds the browser dies and gives a connection error (I allowed my browser through firewalls etc. which hasn't helped). Trying to call the notebook again from the command line results in an "Unable to create process using 'C:\Users\user\miniconda3\envs\envname\python.exe C:\Users\user\miniconda3\envs\envname\Scripts\jupyter-notebook-script.py'
error, after which calling "where python
" on the command line only returns the base kernel, and loses all connection to the environment kernel.
In the VS Code case using the jupyter extension, I correctly get prompted to choose a python interpreter and successfully manage again to execute cells for about 5-10 seconds, until VS Code returns an "Error: Direct kernel connection broken" after which again the kernel just completely vanishes from both the command line and the kernel menu in VS Code.
No files in the environments seem to have changed (AFAIK) and I am completely baffled as to what is going on.
Throughout all of these the base kernel seems to run fine, so I'd venture a guess this has something to do with the way jupyter calls the environment kernel and somehow breaks them in the process. I was successfully running a number of environments for months before on the same setup. The problem initially occurred when I created a new environment, launched VS Code for that environment which inadvertently did not have ipykernel installed, and after getting a prompt from VS Code asking me to install ipykernel, every pre-existing environment consistently started failing in the way described above. After this I reinstalled Anaconda and I have been unable to get a single environment to work.
A minimal example of how the environments were typically created:
conda create --name envname_1 python=3.7
and in testing and installing some packages with conda I cloned the base environment a number of times to sequentially test whether the kernel keeps failing with
conda create --name envname_2 --clone envname_1
and so on. Regardless of the environment the problem persists. After activating the environment with
conda activate envname
asking "where python
" within the environment initially correctly returns
C:\Users\user\miniconda3\envs\envname\python.exe
C:\Users\user\miniconda3\python.exe
and after calling the kernel in some jupyter-context and having it fail, "where python
" from the command line returns just
C:\Users\user\miniconda3\python.exe
I am running on Windows 10 Home 64-bit (version 2004, OS build 19041.867), miniconda3 4.9.2 with base environment python 3.8.5 (the environment kernels tested have mainly been 3.7.x, but 3.8.x has not made a difference so far in testing). Miniconda is installed in my C:\Users\user\miniconda3 directory. (I'm not sure what other details would be helpful here).
So far I've tried:
Purging everything conda-related or python-related from my computer as completely as possible, by using 1) anaconda-clean and then removing the "envs" and "pkgs" folders separately before running the uninstall from standard conda. Miniconda is just the latest n-th reinstall after which the same issues persist.
Setting up a number of test environments in different ways and sequentially testing where the error occurs - seems to always be when activating the kernel one way or another
Removing all possibly related path variables prior to reinstalling
Removing all other python versions (which correctly started pointing python to the base environment - before this an additional problem was the each environment on the command line was attempting to point to my global python installation instead of either the base or environment kernels - this might be somehow related to what is going on here)
Trying all kinds of other little things related to jupyter-notebooks losing kernels within the notebooks, but mostly those have not been applicable since I cannot even use the command line after calling the kernel to work once.
Verified at each step when creating new environments that the environment kernel is correctly pointed to in the environment until calling it from jupyter or VS Code (+ jupyter lab seems to have the same outcome)
I'm a humble man and don't ask for much, would just like to keep working with isolated environments in the future as well. I'm not exactly a whiz when it comes to these things so I'm unsure where else I should be looking or what else I should be trying. Am starting to lose hope as I've been trying to figure this out for a good week now with nothing to show for it.
I hope I'm just being an idiot and overlooking something simple and obvious here since I've not managed to find any similar issues having been resolved. Regardless, any ideas on where I might look to next would be invaluable!