无法在Windows上的新conda环境中打开jupyter笔记本电脑

时间:2018-09-29 00:43:26

标签: python windows anaconda jupyter-notebook

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

长时间使用python Mac的用户。第一次使用python Windows的用户(Windows 7企业版)。

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

Jupyter笔记本可以在基本环境中正常工作。

创建新环境时,无法打开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笔记本[I 18:53:24.082   NotebookApp]从本地目录服务笔记本:C:\ Users \ 13 1416   [I 18:53:24.084 NotebookApp] Jupyter Notebook运行于:[I   18:53:24.085 NotebookApp]   http://localhost:8888/?token=2ecb94399a83d9dc1f8f11   6e0f28a46e297033c1fd796e23 [I 18:53:24.086 NotebookApp]使用Control-C   停止该服务器并关闭所有内核(两次跳过)   确认)。 [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]接受   一次性令牌认证的连接从rom :: 1 [W 18:53:31.615   NotebookApp] 404 GET / undefined(:: 1)12.00ms Referer = None [I   18:53:31.631 NotebookApp]在[E 18:53:32.420]中创建新笔记本   NotebookApp]无法运行命令:       ['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   文件(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 \生产力工具; c:\ Program文件   (x86)\ CA \ SC \ Csam \ SockAdapter \ bin; c:\ Program文件   (x86)\ CA \ SC \ Csam \ SockAdapter \ bin64; c:\ Program Files(x86)\   \ ca \ sc \ CBB \; c:\ Program文件   (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'           与kwargs:       {'stdin':-1,'stdout':无,'stderr':无,'cwd':'C:\ Users \ 131416'}

     

[E 18:53:32.441 NotebookApp]未捕获的异常POST / api / sessions   (:: 1)       HTTPServerRequest(protocol ='http',host ='localhost:8888',method ='POST',uri   ='/ api / sessions',版本='HTTP / 1.1',remote_ip =':: 1')       追溯(最近一次通话):         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ tornado \ web.py”,行159,在_execute中           结果=产量结果         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ tornado \ gen.py“,行1133,正在运行           值= future.result()         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ tornado \ gen.py“,行1141,正在运行           产生= self.gen.throw(* exc_info)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ notebook \ services \ sessions \ handlers.py“,第73行,在   发布           type = mtype))         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ tornado \ gen.py“,行1133,正在运行           值= future.result()         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ tornado \ gen.py“,行1141,正在运行           产生= self.gen.throw(* exc_info)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ notebook \ services \ sessions \ sessionmanager.py“,第79行,   在创造   _session           kernel_id = yield self.start_kernel_for_session(session_id,路径,名称,类型,kernel_name)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ tornado \ gen.py“,行1133,正在运行           值= future.result()         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ tornado \ gen.py“,行1141,正在运行           产生= self.gen.throw(* exc_info)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ notebook \ services \ sessions \ sessionmanager.py“,第92行,   在start_ kernel_for_session中           self.kernel_manager.start_kernel(路径=内核路径,kernel_name =内核_我)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ tornado \ gen.py“,行1133,正在运行           值= future.result()         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ tornado \ gen.py“,第326行,在包装器中           产生=下一个(结果)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ notebook \ services \ kernels \ kernelmanager.py“,第160行,   在start_k ernel中           超级(MappingKernelManager,self).start_kernel(** kwargs)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ jupyter_client \ multikernelmanager.py“,第110行,在   start_kernel           km.start_kernel(** kwargs)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ jupyter_client \ manager.py“,第259行,位于start_kernel中           **千瓦)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ jupyter_client \ manager.py“,第204行,在_launch_kernel中           返回launch_kernel(kernel_cmd,** kw)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ site-packages \ jupyter_client \ launcher.py“,第128行,在launch_kernel中           proc = Popen(cmd,** kwargs)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ subprocess.py”,第709行, init           restore_signals,start_new_session)         文件“ C:\ Users \ 131416 \ AppData \ Local \ Continuum \ anaconda3 \ envs \ test_env2 \ lib   \ subprocess.py”,行_execute_child中的第997行           startupinfo)       FileNotFoundError:[WinError 2]系统找不到指定的文件[W 18:53:32.480 NotebookApp]未处理的错误[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”,         “接受语言”:“ en-US”,         “ Accept-Encoding”:“ gzip,deflate”,         “ User-Agent”:“ Mozilla / 5.0(Windows NT 6.1; WOW64; Trident / 7.0; rv:11.0),例如Gecko”,         “ Host”:“ localhost:8888”,         “ Content-Length”:“ 91”,         “连接”:“保持活动”,         “ Cache-Control”:“ no-cache”,         “ Cookie”:“ username-localhost-8888 = \” 2 | 1:0 | 10:1538175204 | 23:username-local   主机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 \“;   用户名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]将文件保存在/Untitled.ipynb

5 个答案:

答案 0 :(得分:1)

激活环境后,请安装ipykernel

conda install ipykernel

然后运行

jupyter notebook

答案 1 :(得分:0)

conda activate new_env_name

在MacOS下激活

source activate new_ene_name

在Windows下

答案 2 :(得分:0)

对于Windows 7不能说,但是对于Windows 10来说,请启动命令提示符,导航到所选目录,然后激活您的环境,例如:

main1

从这里启动笔记本电脑

activate my_env

注意,从powershell这样做对我来说不起作用,因此我使用命令提示符。

或者,在Windows 10中,可以使用Windows商店中的本机Linux探索启动终端。

答案 3 :(得分:0)

不确定这是否对您有很大帮助,但如果您使用的是 Docker,您可以执行以下操作:

  1. 创建一个包含以下内容的 Dockerfile
FROM jupyter/datascience-notebook

RUN pip install -U pip

ENV JUPYTER_ENABLE_LAB=yes

COPY --chown=${NB_UID}:${NB_GID} . /home/vishesh/work
WORKDIR /home/vishesh/work

CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--notebook-dir=/home/vishesh/work", "--allow-root"]
  1. 创建 docker-compose.yml
version: '3.7'

services:
  jupyterlab:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "8888:8888"
    volumes:
      - ./notebooks:/home/vishesh/work
 
  1. 两个文件应该在同一个文件夹中
  2. 在当前目录下依次打开PowerShell和下面的命令 docker-compose build docker-compose up
  3. 一旦所有服务开始出现在 PowerShell 窗口中运行。 转到您的浏览器并打开 http://localhost:8888

这只是为了证明直接使用虚拟化选项而不是自己安装所有东西是多么容易。

答案 4 :(得分:0)

激活新环境,然后安装 jupyter

conda install ipykernel
pip3 install jupyter

然后使用 conda 和 pip 安装所需的库以处理您的项目