是否可以从虚拟环境中运行jupyter

时间:2020-01-15 09:40:19

标签: python jupyter-notebook virtualenv

现在我仅使用python 2.7(已为所有用户安装,已添加到Windows 10计算机的路径中),但我想切换到3.8,以便能够同时使用这两个版本,我首先在系统python 2.7中安装了virtualenv

然后为所有用户安装了python 3.8.1,而没有将其添加到路径中。

这样创建我的virtualenv:virtualenv c:\virtualEnvs\p38x64_jupytertest -p C:\Python38-32\python.exe

  • 然后将其激活:C:\virtualEnvs\p38x64_jupytertest\Scripts\activate.bat
  • 检查是否已使用python --version选择了python 3.8.1
  • 然后将jupyter安装在我的virtualenv中:pip install jupyter

然后当我运行jupyter notebook

Traceback (most recent call last):
  File "C:\Python38-32\Lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python38-32\Lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "c:\virtualEnvs\p38x64_jupytertest3\Scripts\jupyter-notebook.EXE\__main__.py", line 7, in <module>
  File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\jupyter_core\application.py", line 268, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\traitlets\config\application.py", line 663, in launch_instance
    app.initialize(argv)
  File "<c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\decorator.py:decorator-gen-7>", line 2, in initialize
  File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\notebook\notebookapp.py", line 1720, in initialize
    self.init_webapp()
  File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\notebook\notebookapp.py", line 1482, in init_webapp
    self.http_server.listen(port, self.ip)
  File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\tcpserver.py", line 152, in listen
    self.add_sockets(sockets)
  File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
    self._handlers[sock.fileno()] = add_accept_handler(
  File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
    io_loop.add_handler(sock, accept_handler, IOLoop.READ)
  File "c:\virtualenvs\p38x64_jupytertest3\lib\site-packages\tornado\platform\asyncio.py", line 99, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "C:\Python38-32\Lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

经过一番谷歌搜索后,我发现了很多教程,它们解释了如何在系统python中安装jupyter,然后向其中添加virtualenvs,而不是如何在虚拟env中安装它。

之所以这样做,是因为我希望隔离python 3项目,因为我有很多python 2.7项目(到现在为止,我还没有使用virtualenv,并且每个软件包都安装在系统python 2中。)< / p>

我为什么会有这个例外的任何想法?

谢谢。

PS:是的,它在堆栈跟踪中显示p38x64_jupytertest3,因为实际上venv不是p38x64_jupytertest,而是p38x64_jupytertest3

1 个答案:

答案 0 :(得分:1)

知道问题:https://github.com/jupyter/notebook/issues/4613

暂时恢复到python 3.7