Python Jupyter笔记本:连接到服务器时出错

Python Jupyter笔记本:连接到服务器时出错,python,python-3.x,jupyter-notebook,anaconda,virtualenv,Python,Python 3.x,Jupyter Notebook,Anaconda,Virtualenv,我刚刚安装了最新的python版本(3.8.5)(Anaconda发行版),同时正确地遵循了文档中提到的所有步骤 然后我尝试使用以下方法将其添加到我的Jupyter笔记本中: python -m ipykernel install --user --name=Python3.8.5 [Python 3.8.5是环境的名称] 我成功地将它添加到jupyter笔记本中 但当我试图使用Jupyter笔记本访问它时,它显示的是: jupyter notebook命令行中的回溯如下所示: To

我刚刚安装了最新的python版本(3.8.5)(Anaconda发行版),同时正确地遵循了文档中提到的所有步骤

然后我尝试使用以下方法将其添加到我的Jupyter笔记本中:

python -m ipykernel install --user --name=Python3.8.5
[Python 3.8.5是环境的名称]

我成功地将它添加到jupyter笔记本中

但当我试图使用Jupyter笔记本访问它时,它显示的是: jupyter notebook命令行中的回溯如下所示:

    To access the notebook, open this file in a browser:
        file:///C:/Users/aakash/AppData/Roaming/jupyter/runtime/nbserver-5272-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=53898b31bc28a966e6576d5e20099d192dc5c95ddff14a4c
     or http://127.0.0.1:8888/?token=53898b31bc28a966e6576d5e20099d192dc5c95ddff14a4c
[I 16:56:48.967 NotebookApp] Creating new notebook in
[I 16:56:57.277 NotebookApp] Kernel started: 09f6bfbd-6e88-4264-a4a3-c975801012bc, name: python3.8.5
Traceback (most recent call last):
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\ipykernel_launcher.py", line 16, in <module>
    app.launch_new_instance()
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\traitlets\config\application.py", line 836, in launch_instance
    app.initialize(argv)
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\traitlets\config\application.py", line 86, in inner
    return method(app, *args, **kwargs)
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 570, in initialize
    self.write_connection_file()
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 230, in write_connection_file
    write_connection_file(cf, ip=self.ip, key=self.session.key, transport=self.transport,
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\jupyter_client\connect.py", line 138, in write_connection_file
    with secure_write(fname) as f:
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\jupyter_core\paths.py", line 435, in secure_write
    win32_restrict_file_to_user(fname)
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\jupyter_core\paths.py", line 361, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed while importing win32api: The specified module could not be found.
[I 16:57:00.140 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\aakash\\AppData\\Roaming\\jupyter\\runtime\\kernel-09f6bfbd-6e88-4264-a4a3-c975801012bc.json'
Traceback (most recent call last):
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 257, in init_connection_file
    self.load_connection_file()
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\jupyter_client\connect.py", line 496, in load_connection_file
    info = json.load(f)
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 16:57:03.144 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\aakash\\AppData\\Roaming\\jupyter\\runtime\\kernel-09f6bfbd-6e88-4264-a4a3-c975801012bc.json'
Traceback (most recent call last):
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 257, in init_connection_file
    self.load_connection_file()
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\jupyter_client\connect.py", line 496, in load_connection_file
    info = json.load(f)
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 16:57:06.150 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\aakash\\AppData\\Roaming\\jupyter\\runtime\\kernel-09f6bfbd-6e88-4264-a4a3-c975801012bc.json'
Traceback (most recent call last):
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 257, in init_connection_file
    self.load_connection_file()
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\jupyter_client\connect.py", line 496, in load_connection_file
    info = json.load(f)
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[I 16:57:09.159 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
[IPKernelApp] ERROR | Failed to load connection file: 'C:\\Users\\aakash\\AppData\\Roaming\\jupyter\\runtime\\kernel-09f6bfbd-6e88-4264-a4a3-c975801012bc.json'
Traceback (most recent call last):
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\ipykernel\kernelapp.py", line 257, in init_connection_file
    self.load_connection_file()
  File "C:\Users\aakash\AppData\Roaming\Python\Python38\site-packages\jupyter_client\connect.py", line 496, in load_connection_file
    info = json.load(f)
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\__init__.py", line 293, in load
    return loads(fp.read(),
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
[W 16:57:12.163 NotebookApp] KernelRestarter: restart failed
[W 16:57:12.163 NotebookApp] Kernel 09f6bfbd-6e88-4264-a4a3-c975801012bc died, removing from map.
[W 16:57:57.333 NotebookApp] Timeout waiting for kernel_info reply from 09f6bfbd-6e88-4264-a4a3-c975801012bc
[E 16:57:57.333 NotebookApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: 09f6bfbd-6e88-4264-a4a3-c975801012bc)
[W 16:57:58.366 NotebookApp] 404 GET /api/kernels/09f6bfbd-6e88-4264-a4a3-c975801012bc/channels?session_id=7b5b1d566bd249d981caaf4631317e38 (::1): Kernel does not exist: 09f6bfbd-6e88-4264-a4a3-c975801012bc
[W 16:57:58.400 NotebookApp] 404 GET /api/kernels/09f6bfbd-6e88-4264-a4a3-c975801012bc/channels?session_id=7b5b1d566bd249d981caaf4631317e38 (::1) 35.90ms referer=None
[W 16:58:00.426 NotebookApp] Replacing stale connection: 09f6bfbd-6e88-4264-a4a3-c975801012bc:7b5b1d566bd249d981caaf4631317e38
[I 16:58:57.356 NotebookApp] Saving file at /Untitled5.ipynb
[W 17:02:05.348 NotebookApp] Replacing stale connection: 09f6bfbd-6e88-4264-a4a3-c975801012bc:7b5b1d566bd249d981caaf4631317e38
[W 17:06:13.365 NotebookApp] Replacing stale connection: 09f6bfbd-6e88-4264-a4a3-c975801012bc:7b5b1d566bd249d981caaf4631317e38
要访问笔记本,请在浏览器中打开此文件:
file:///C:/Users/aakash/AppData/Roaming/jupyter/runtime/nbserver-5272-open.html
或复制并粘贴以下URL之一:
http://localhost:8888/?token=53898b31bc28a966e6576d5e20099d192dc5c95ddff14a4c
或http://127.0.0.1:8888/?token=53898b31bc28a966e6576d5e20099d192dc5c95ddff14a4c
[I 16:56:48.967 NotebookApp]在中创建新笔记本
[I 16:56:57.277 NotebookApp]内核已启动:09f6bfbd-6e88-4264-a4a3-c975801012bc,名称:python3.8.5
回溯(最近一次呼叫最后一次):
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\runpy.py”,第194行,位于主运行模块中
返回运行代码(代码、主全局、无、,
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\runpy.py”,第87行,在运行代码中
exec(代码、运行\全局)
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\ipykernel\u launcher.py”,第16行,在
app.launch_new_instance()
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\traitlets\config\application.py”,第836行,在launch\u实例中
应用程序初始化(argv)
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\traitlets\config\application.py”,第86行,在内部
返回方法(应用程序、*args、**kwargs)
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\ipykernel\kernelapp.py”,第570行,在初始化中
self.write_连接_文件()
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\ipykernel\kernelapp.py”,第230行,在write\u connection\u文件中
写入连接文件(cf,ip=self.ip,key=self.session.key,transport=self.transport,
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\jupyter\u client\connect.py”,第138行,在write\u connection\u文件中
将安全_写入(fname)作为f:
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\contextlib.py”,第113行,输入__
返回下一个(self.gen)
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\jupyter\u core\path.py”,第435行,安全写入
win32\u将\u文件\u限制为\u用户(fname)
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\jupyter\u core\path.py”,第361行,在win32\u restrict\u File\u to\u user中
导入win32api
ImportError:导入win32api时DLL加载失败:找不到指定的模块。
[I 16:57:00.140 NotebookApp]内核重启器:重新启动内核(1/5),新的随机端口
[IPKernelApp]错误|加载连接文件失败:“C:\\Users\\aakash\\AppData\\Roaming\\jupyter\\runtime\\kernel-09f6bfbd-6e88-4264-a4a3-c975801012bc.json”
回溯(最近一次呼叫最后一次):
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\ipykernel\kernelapp.py”,第257行,在init\u connection\u文件中
self.load\u连接\u文件()
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\jupyter\u client\connect.py”,第496行,在load\u connection\u文件中
info=json.load(f)
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\\ uu_init\u_uu.py”,第293行,已加载
返回加载(fp.read(),
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\\ uu_init\u_uu.py”,第357行,在loads中
返回\u默认\u解码器。解码
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py”,第337行,在decode中
obj,end=self.raw\u decode(s,idx=\u w(s,0.end())
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py”,第355行,原始解码
从None引发JSONDecodeError(“预期值”,s,err.value)
json.decoder.JSONDecodeError:预期值:第1行第1列(字符0)
[I 16:57:03.144 NotebookApp]内核重启器:重新启动内核(2/5),新的随机端口
[IPKernelApp]错误|加载连接文件失败:“C:\\Users\\aakash\\AppData\\Roaming\\jupyter\\runtime\\kernel-09f6bfbd-6e88-4264-a4a3-c975801012bc.json”
回溯(最近一次呼叫最后一次):
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\ipykernel\kernelapp.py”,第257行,在init\u connection\u文件中
self.load\u连接\u文件()
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\jupyter\u client\connect.py”,第496行,在load\u connection\u文件中
info=json.load(f)
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\\ uu_init\u_uu.py”,第293行,已加载
返回加载(fp.read(),
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\\ uu_init\u_uu.py”,第357行,在loads中
返回\u默认\u解码器。解码
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py”,第337行,在decode中
obj,end=self.raw\u decode(s,idx=\u w(s,0.end())
文件“C:\Users\aakash\Anaconda3\envs\Python3.8.5\lib\json\decoder.py”,第355行,原始解码
从None引发JSONDecodeError(“预期值”,s,err.value)
json.decoder.JSONDecodeError:预期值:第1行第1列(字符0)
[I 16:57:06.150 NotebookApp]内核重启器:重新启动内核(3/5),新的随机端口
[IPKernelApp]错误|加载连接文件失败:“C:\\Users\\aakash\\AppData\\Roaming\\jupyter\\runtime\\kernel-09f6bfbd-6e88-4264-a4a3-c975801012bc.json”
回溯(最近一次呼叫最后一次):
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\ipykernel\kernelapp.py”,第257行,在init\u connection\u文件中
self.load\u连接\u文件()
文件“C:\Users\aakash\AppData\Roaming\Python38\site packages\jupyter\u client\connect.py”,第496行,在load\u connection\u文件中
info=json.load(f)
文件“C:\Users\a
conda activate Python3.8.5
pip install pywin32
cd C:\Users\aakash\anaconda3\envs\Python3.8.5\Scripts
conda activate Python3.8.5
python pywin32_postinstall.py -install