Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can't open jupyter notebook in new conda environment on windows

Edit: This seem to be a conda-forge issue. conda install jupyter works fine. Opened issue on GitHub: https://github.com/conda-forge/jupyter-feedstock/issues/6

Long time python Mac user. First time python windows users (windows 7 enterprise).

Installed python via Anaconda (https://repo.anaconda.com/archive/Anaconda3-5.2.0-Windows-x86_64.exe)

Jupyter notebook works fine in the base environment.

When I create a new environment I cannot open jupyter notebook.

Open Anaconda Prompt:

conda create -n test_env2 python=3.6
conda activate test_env2
conda install -c conda-forge jupyter
jupyter notebook

When I open an Ipython notebook it shows 'Kernel error': enter image description here

and the obvious errors are:

[E 18:53:32.420 NotebookApp] Failed to run command:
['C:/Users/131416/AppData/Local/Continuum/anaconda3/envs/test_env2/bin/python', '-m', 'ipykernel_launcher', '-f', 'C:\\Users\\131416\\AppData\\Roaming\\jupyter\\runtime\\kernel-99e95812-0a80-4772-94fc-e35563ce58e1.json']

  File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib\subprocess.py", 
line 997, in _execute_child
   startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

[E 18:53:32.498 NotebookApp] 500 POST /api/sessions (::1) 135.50ms referer=http://localhost:8888/notebooks/Untitled.ipynb?kernel_name=python3

Perhaps it has something to do with it picking up jupyter.exe in the base environment as well as the jupyter.exe in the new environment: enter image description here

There is also some discussion in https://github.com/jupyter/notebook/issues/2130 but the solutions aren't obvious.

The full Traceback is (apologies for the layout. Copied from cmd):

(test_env2) C:\Users\131416>jupyter notebook [I 18:53:24.082 NotebookApp] Serving notebooks from local directory: C:\Users\13 1416 [I 18:53:24.084 NotebookApp] The Jupyter Notebook is running at: [I 18:53:24.085 NotebookApp] http://localhost:8888/?token=2ecb94399a83d9dc1f8f11 6e0f28a46e297033c1fd796e23 [I 18:53:24.086 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 18:53:24.089 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
    http://localhost:8888/?token=2ecb94399a83d9dc1f8f116e0f28a46e297033c1fd7

96e23 [I 18:53:24.384 NotebookApp] Accepting one-time-token-authenticated connection f rom ::1 [W 18:53:31.615 NotebookApp] 404 GET /undefined (::1) 12.00ms referer=None [I 18:53:31.631 NotebookApp] Creating new notebook in [E 18:53:32.420 NotebookApp] Failed to run command: ['C:/Users/131416/AppData/Local/Continuum/anaconda3/envs/test_env2/bin/pytho n', '-m', 'ipykernel_launcher', '-f', 'C:\Users\131416\AppData\Roaming\jupy ter\runtime\kernel-99e95812-0a80-4772-94fc-e35563ce58e1.json'] PATH='C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\tes t_env2;C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\ \Library\mingw-w64\bin;C:\Users\131416\AppData\Local\Continuum\anaconda3 \envs\test_env2\Library\usr\bin;C:\Users\131416\AppData\Local\Continuu m\anaconda3\envs\test_env2\Library\bin;C:\Users\131416\AppData\Local\C ontinuum\anaconda3\envs\test_env2\Scripts;C:\Users\131416\AppData\Local\ \Continuum\anaconda3\envs\test_env2\bin;C:\Users\131416\AppData\Local\C ontinuum\anaconda3;C:\Users\131416\AppData\Local\Continuum\anaconda3\Lib rary\mingw-w64\bin;C:\Users\131416\AppData\Local\Continuum\anaconda3\Li brary\usr\bin;C:\Users\131416\AppData\Local\Continuum\anaconda3\Library \bin;C:\Users\131416\AppData\Local\Continuum\anaconda3\Scripts;C:\Users \131416\AppData\Local\Continuum\anaconda3\bin;c:\Program Files (x86)\ca\ \sc\CAWIN\;C:\ProgramData\Oracle\Java\javapath;C:\windows\system32;C:\w indows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1. 0\;C:\Program Files (x86)\Symantec\VIP Access Client\;C:\Program Files (x8 6)\IBM\Client Access\Emulator;C:\Program Files (x86)\IBM\Client Access\Sh ared;C:\Program Files (x86)\IBM\Client Access\;C:\Program Files (x86)\WebE x\Productivity Tools;c:\Program Files (x86)\CA\SC\Csam\SockAdapter\bin;c: \Program Files (x86)\CA\SC\Csam\SockAdapter\bin64;c:\Program Files (x86)\ \ca\sc\CBB\;c:\Program Files (x86)\ca\DSM\bin;c:\PROGRA~2\ca\sc\CAM\ bin;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel \WirelessCommon\;C:\Program Files\Microsoft VS Code\bin' with kwargs: {'stdin': -1, 'stdout': None, 'stderr': None, 'cwd': 'C:\Users\131416'}

[E 18:53:32.441 NotebookApp] Uncaught exception POST /api/sessions (::1) HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri ='/api/sessions', version='HTTP/1.1', remote_ip='::1') Traceback (most recent call last): File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\tornado\web.py", line 1592, in _execute result = yield result File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\tornado\gen.py", line 1133, in run value = future.result() File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\tornado\gen.py", line 1141, in run yielded = self.gen.throw(*exc_info) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\notebook\services\sessions\handlers.py", line 73, in post type=mtype)) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\tornado\gen.py", line 1133, in run value = future.result() File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\tornado\gen.py", line 1141, in run yielded = self.gen.throw(*exc_info) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\notebook\services\sessions\sessionmanager.py", line 79, in create _session kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\tornado\gen.py", line 1133, in run value = future.result() File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\tornado\gen.py", line 1141, in run yielded = self.gen.throw(*exc_info) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\notebook\services\sessions\sessionmanager.py", line 92, in start_ kernel_for_session self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_na me) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\tornado\gen.py", line 1133, in run value = future.result() File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\tornado\gen.py", line 326, in wrapper yielded = next(result) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\notebook\services\kernels\kernelmanager.py", line 160, in start_k ernel super(MappingKernelManager, self).start_kernel(**kwargs) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel km.start_kernel(**kwargs) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\jupyter_client\manager.py", line 259, in start_kernel **kw) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\jupyter_client\manager.py", line 204, in _launch_kernel return launch_kernel(kernel_cmd, **kw) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \site-packages\jupyter_client\launcher.py", line 128, in launch_kernel proc = Popen(cmd, **kwargs) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \subprocess.py", line 709, in init restore_signals, start_new_session) File "C:\Users\131416\AppData\Local\Continuum\anaconda3\envs\test_env2\lib \subprocess.py", line 997, in _execute_child startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified [W 18:53:32.480 NotebookApp] Unhandled error [E 18:53:32.482 NotebookApp] { "Accept": "application/json, text/javascript, /; q=0.01", "Content-Type": "application/json", "X-Xsrftoken": "2|d69ec7c3|9a70043f110f803ee6ab3273dd14309a|1538153699", "X-Requested-With": "XMLHttpRequest", "Referer": "http://localhost:8888/notebooks/Untitled.ipynb?kernel_name=pyt hon3", "Accept-Language": "en-US", "Accept-Encoding": "gzip, deflate", "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) l ike Gecko", "Host": "localhost:8888", "Content-Length": "91", "Connection": "Keep-Alive", "Cache-Control": "no-cache", "Cookie": "username-localhost-8888=\"2|1:0|10:1538175204|23:username-local host-8888|44:Y2MwOTgzODhmZDZhNGE4NzhmM2Q2NWJjMDI2MjVjZjc=|a3c49f08f13669a523498b 9125cf42ce7eaab53181c1441544fcf533a94545da\"; _xsrf=2|d69ec7c3|9a70043f110f803ee 6ab3273dd14309a|1538153699; username-localhost-8889=\"2|1:0|10:1538162170|23:use rname-localhost-8889|44:NWQzZWQwZDY3ZmMzNDAzM2I5NDI4ZWI5OTA5NTkwZDc=|d515096d015 d24b1e06638fa64fc2c7b145a17c411203fd4141733f0a7815b9a\"; username-localhost-8890 =\"2|1:0|10:1538162261|23:username-localhost-8890|44:YTU3NmY5MDczNzNmNGNjMTg1MzU yYjkyODU3ZDE5Y2I=|342bc9d819999a050780d4dbef1f9ade1e69fe3f52914132a9b897a0f3023a f2\"" } [E 18:53:32.498 NotebookApp] 500 POST /api/sessions (::1) 135.50ms referer=http: //localhost:8888/notebooks/Untitled.ipynb?kernel_name=python3 [I 18:55:32.687 NotebookApp] Saving file at /Untitled.ipynb

like image 753
Ray Bell Avatar asked Jan 01 '23 19:01

Ray Bell


1 Answers

After activating the environment, please install ipykernel

conda install ipykernel

and then run

jupyter notebook
like image 182
Anju Paul - Intel Avatar answered Jan 13 '23 12:01

Anju Paul - Intel