Kernel dies in newly created conda environments win10

Hello everyone,

I’ve tried for 2 days to create a new environment in conda with a kernel for Jupyter from which to run Jupyter Notebook, but the kernel keeps dying if I try to execute scripts on it. From my base conda environment everything runs fine, here are its specifications:

 active environment : base
active env location : C:\Users\Vaandrager\anaconda3
        shell level : 1
   user config file : C:\Users\Vaandrager\.condarc

populated config files : C:\Users\Vaandrager.condarc
conda version : 4.8.2
conda-build version : 3.18.11
python version : 3.7.6.final.0
virtual packages :
base environment : C:\Users\Vaandrager\anaconda3 (writable)
channel URLs : /main/win-64 ##with a correct URL infront which Im not allowed to post
/main/noarch
/r/win-64
/r/noarch
/msys2/win-64
/msys2/noarch
package cache : C:\Users\Vaandrager\anaconda3\pkgs
C:\Users\Vaandrager.conda\pkgs
C:\Users\Vaandrager\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\Vaandrager\anaconda3\envs
C:\Users\Vaandrager.conda\envs
C:\Users\Vaandrager\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.8.2 requests/2.22.0 CPython/3.7.6 Windows/10 Windows/10.0.18362
administrator : False
netrc file : None
offline mode : False

I use the following commands to create an environment using the anaconda prompt:
conda create -n python2_env python=2 ipykernel jupyter
conda activate python2_env
python -m ipykernel install --user --name python2_env --display-name “python2_env”

This is the kernelspec list
(base) C:\Users\Vaandrager>jupyter kernelspec list
Available kernels:
python2_env C:\Users\Vaandrager\AppData\Roaming\jupyter\kernels\python2_env
python3 C:\Users\Vaandrager\anaconda3\share\jupyter\kernels\python3

If I check the kernel.json file where it was installed it looks similar to the base kernel file, except that it points to the anaconda3\envs\python2_env\python.exe instead of anaconda3\python.exe (which I think is the whole point).

If I open jupyter notebook from the conda prompt from the python2_env or if I open jupyter notebook from base and then change kernels, the notebook opens initially, but after a few seconds or if I execute a cell, the kernel dies, giving the following error (here I have opened jupyter notebook from base, then opened an example ipynb (in this case a cplex example notebook) and then switched kernel to the newly created kernel in a seperate conda environment):

(base) C:\Users\Vaandrager>jupyter notebook
[I 09:39:31.139 NotebookApp] JupyterLab extension loaded from C:\Users\Vaandrager\Anaconda3\lib\site-packages\jupyterlab
[I 09:39:31.139 NotebookApp] JupyterLab application directory is C:\Users\Vaandrager\Anaconda3\share\jupyter\lab
[I 09:39:31.170 NotebookApp] Serving notebooks from local directory: C:\Users\Vaandrager
[I 09:39:31.170 NotebookApp] The Jupyter Notebook is running at:
[I 09:39:31.170 NotebookApp] URL #not allowed to post
[I 09:39:31.170 NotebookApp] or URL #not allowed to post
[I 09:39:31.170 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:39:31.248 NotebookApp]

To access the notebook, open this file in a browser:
    file:///C:/Users/Vaandrager/AppData/Roaming/jupyter/runtime/nbserver-3764-open.html
Or copy and paste one of these URLs:
     URL #not allowed to post
 or  URL #not allowed to post

[W 09:39:58.141 NotebookApp] Notebook Documents/IBM/ILOG/CPLEX_Studio_Community129/python/examples/cp/jupyter/house_building.ipynb is not trusted
[I 09:40:06.454 NotebookApp] Kernel started: 22513916-1e6b-47db-9341-621c49f7c53f
[I 09:40:07.728 NotebookApp] Adapting from protocol version 5.1 (kernel 22513916-1e6b-47db-9341-621c49f7c53f) to 5.3 (client).
[I 09:40:15.434 NotebookApp] KernelRestarter: restarting kernel (1/5), keep random ports
kernel 22513916-1e6b-47db-9341-621c49f7c53f restarted
[E 09:40:15.449 NotebookApp] Failed to run command:
[‘C:\Users\Vaandrager\anaconda3\envs\python2_env\python.exe’, ‘-m’, ‘ipykernel_launcher’, ‘-f’, ‘C:\Users\Vaandrager\AppData\Roaming\jupyter\runtime\kernel-22513916-1e6b-47db-9341-621c49f7c53f.json’]
PATH=‘C:\Users\Vaandrager\Anaconda3;C:\Users\Vaandrager\Anaconda3\Library\mingw-w64\bin;C:\Users\Vaandrager\Anaconda3\Library\usr\bin;C:\Users\Vaandrager\Anaconda3\Library\bin;C:\Users\Vaandrager\Anaconda3\Scripts;C:\Users\Vaandrager\Anaconda3\bin;C:\Users\Vaandrager\anaconda3\condabin;C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\opl\bin\x64_win64;C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\opl\oplide;C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cplex\bin\x64_win64;C:\Program Files\IBM\ILOG\CPLEX_Studio_Community129\cpoptimizer\bin\x64_win64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git\cmd;C:\Program Files (x86)\Wolfram Research\WolframScript;C:\Users\Vaandrager\AppData\Local\Microsoft\WindowsApps;C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.4\bin;.;C:\Program Files\JetBrains\PyCharm 2019.3.4\bin;.;.’
with kwargs:
{‘stdin’: -1, ‘stdout’: None, ‘stderr’: None, ‘cwd’: ‘C:\Users\Vaandrager\Documents\IBM\ILOG\CPLEX_Studio_Community129\python\examples\cp\jupyter’, ‘close_fds’: False}

[E 09:40:15.450 NotebookApp] Exception in callback <bound method KernelRestarter.poll of <jupyter_client.ioloop.restarter.IOLoopKernelRestarter object at 0x00000234E1282708>>
Traceback (most recent call last):
File “C:\Users\Vaandrager\Anaconda3\lib\site-packages\tornado\ioloop.py”, line 907, in _run
return self.callback()
File “C:\Users\Vaandrager\Anaconda3\lib\site-packages\jupyter_client\restarter.py”, line 113, in poll
self.kernel_manager.restart_kernel(now=True, newports=newports)
File “C:\Users\Vaandrager\Anaconda3\lib\site-packages\jupyter_client\manager.py”, line 368, in restart_kernel
self.start_kernel(**self._launch_args)
File “C:\Users\Vaandrager\Anaconda3\lib\site-packages\jupyter_client\manager.py”, line 259, in start_kernel
**kw)
File “C:\Users\Vaandrager\Anaconda3\lib\site-packages\jupyter_client\manager.py”, line 204, in _launch_kernel
return launch_kernel(kernel_cmd, **kw)
File “C:\Users\Vaandrager\Anaconda3\lib\site-packages\jupyter_client\launcher.py”, line 138, in launch_kernel
proc = Popen(cmd, **kwargs)
File “C:\Users\Vaandrager\Anaconda3\lib\subprocess.py”, line 800, in init
restore_signals, start_new_session)
File “C:\Users\Vaandrager\Anaconda3\lib\subprocess.py”, line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system can’t find the file #originally in Dutch
[I 09:42:00.661 NotebookApp] Saving file at /Documents/IBM/ILOG/CPLEX_Studio_Community129/python/examples/cp/jupyter/house_building.ipynb

After this, I can change back to the base (Python 3) kernel which works fine. After this error the newly created anaconda environment (here python2_env) has a whole lot of files less and also the python.exe file is then deleted/gone. I’ve tried installing kernels via nb_conda_kernels and downgrading the pywin32 to version 224 in the python2_env, I have reinstalled anaconda and tried with miniconda, and I have tried creating an environment in the anaconda navigator and theninstalling jupyter notebook for this env through the interface, but nothing seems to work. I don’t think anaconda is the problem, because if I create environments for regular python scripts in pyCharm for example, they work fine, the environment gets ‘corrupted’ after trying to run .ipynb files there or if I open Jupyter Notebook.

I hope someone can help me solve this problem, thanks in advance!