python - windows上新conda环境下无法打开jupyter笔记本

标签 python windows anaconda jupyter-notebook

编辑:这似乎是一个 conda-forge 问题。 conda install jupyter 工作正常。 GitHub 上打开的问题:https://github.com/conda-forge/jupyter-feedstock/issues/6

长期 python Mac 用户。第一次使用 Python Windows 用户(Windows 7 企业版)。

通过 Anaconda 安装了 python ( https://repo.anaconda.com/archive/Anaconda3-5.2.0-Windows-x86_64.exe )

Jupyter Notebook 在基础环境中运行良好。

当我创建新环境时,我无法打开 jupyter 笔记本。

打开 Anaconda 提示符:

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

当我打开 Ipython 笔记本时,它显示“内核错误”: enter image description here

明显的错误是:

[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

也许这与它在基础环境中获取 jupyter.exe 以及在新环境中获取 jupyter.exe 有关: enter image description here

https://github.com/jupyter/notebook/issues/2130中也有一些讨论但解决方案并不明显。

完整的回溯是(对布局表示歉意。从 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

最佳答案

激活环境后,请安装ipykernel

conda install ipykernel

然后运行

jupyter notebook

关于python - windows上新conda环境下无法打开jupyter笔记本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52564114/

相关文章:

Python 非图唯一性

python - 来自python的gcc编译错误

python - 如何高效地执行循环语句进行数据分析?

python - 我可以访问远程机器上的 unix 域套接字吗?

windows - UDP 监听套接字在网络配置更改后停止监听

java - SWT - 如何调试 "No more handles"

python - 为所有 conda 环境安装 OpenCV

python - 我可以使用免费的适用于 Python 2.7 的 Microsoft C++ 编译器来构建 conda 包吗?

python - 在 python 3.6 上使用 conda 安装 ephem

windows - 用于调试异常内存泄漏的调试技术