簡體   English   中英

無法在 Windows 上的新 conda 環境中打開 jupyter notebook

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

編輯:這似乎是一個 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 notebook。

打開 Anaconda 提示:

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

當我打開 Ipython 筆記本時,它顯示“內核錯誤”: 在此處輸入圖片說明

明顯的錯誤是:

[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在新的環境: 在此處輸入圖片說明

https://github.com/jupyter/notebook/issues/2130 中也有一些討論,但解決方案並不明顯。

完整的回溯是(為布局道歉。從cmd復制):

(test_env2) C:\\Users\\131416>jupyter notebook [I 18:53:24.082 NotebookApp] 從本地目錄提供 notebooks: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] 使用Control-tcw to stop this server 確認關閉 Notebook 的所有內核. [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] 接受來自 ::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'] 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\\本地\\連續體\\a naconda3;C:\\Users\\131416\\AppData\\Local\\Continuum\\anaconda3\\Library\\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\\文件;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] 未捕獲異常 POST /api/sessions (::1) HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions ', version='HTTP/1.1', remote_ip='::1') 回溯(最近一次調用最后一次):文件“C:\\Users\\131416\\AppData\\Local\\Continuum\\anaconda3\\envs\\test_env2\\lib\\site -packages\\tornado\\web.py”,第 1592 行,在 _execute result = yield result 文件“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) 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)) 文件 "C:\\Users\\131416\\AppData\\Local\\Continuum\\anaconda3\\envs\\test_env2\\lib\\site-packages\\tornado\\gen.py", line 1133,運行值 = futu re.result() 文件“C:\\Users\\131416\\AppData\\Local\\Continuum\\anaconda3\\envs\\test_env2\\lib\\site-packages\\tornado\\gen.py”,第 1141 行,運行生成 = self.gen。 throw(*exc_info) File "C:\\Users\\131416\\AppData\\Local\\Continuum\\anaconda3\\envs\\test_env2\\lib\\site-packages\\notebook\\services\\sessions\\sessionmanager.py",第 79 行,在 create _session kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, 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(path=kernel_path, kernel_name=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 行,在包裝器中產生 = next(result) 文件“C:\\Users\\131416\\AppData\\Local\\Continuum \\anaconda3\\envs\\test_env2\\lib \\site-packages\\notebook\\services\\kernels\\kernelmanager.py”,第 160 行,在 start_k ernel super(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 **kw)文件“C:\\Users\\131416\\AppData\\Local\\Continuum\\anaconda3\\ envs\\test_env2\\lib \\site-packages\\jupyter_client\\manager.py”,第 204 行,在 _launch_kernel 返回啟動 _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", line 709, in init restore_signals, start_new_session) 文件 "C:\\Users \\131416\\AppData\\Local\\Continuum\\anaconda3\\envs\\test_env2\\lib\\subprocess.py", line 997, in _execute_child 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": "RefHttper" 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) like 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 9125cf42ce7eaab53181c1441544fcf535a945; _xsrf=2|d69ec7c3|9a70043f110f803ee 6ab3273dd14309a|1538153699; 用戶名 - 本地主機-8889 = \\ “2 | 1:0 | 10:1538162170 | 23:使用RNAME-本地主機-8889 | 44:NWQzZWQwZDY3ZmMzNDAzM2I5NDI4ZWI5OTA5NTkwZDc = | d515096d015 d24b1e06638fa64fc2c7b145a17c411203fd4141733f0a7815b9a \\”; 用戶名 - 本地主機-8890 = \\ “2 | 1:0 | 10:1538162261 | 23:用戶名 - 本地主機-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

激活環境后,請安裝ipykernel

conda install ipykernel

然后運行

jupyter notebook
conda activate new_env_name

在 MacOS 下激活

source activate new_ene_name

在 Windows 下

不能說 Windows 7,但對於 Windows 10,啟動命令提示符,導航到選擇的目錄,然后激活您的環境,例如:

activate my_env

從這里啟動你的筆記本:

jupyter notebook

請注意,我無法從 powershell 執行此操作,因此我使用命令提示符。

或者,對於 Windows 10,可以使用本機 linux 探索啟動終端,可通過 Windows 商店獲得。

不確定這是否對您有很大幫助,但如果您正在使用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

這只是為了證明直接使用虛擬化選項而不是自己安裝所有東西是多么容易。

激活新環境,然后安裝jupyter

conda install ipykernel
pip3 install jupyter

然后使用 conda 和 pip 安裝所需的庫以處理您的項目

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM