我在 Windows 10 上新安装了带有 Python 3.7 的 Anaconda 自定义版本。我的 PATH 中有 Anaconda3、Anaconda3\Scripts 和 Anaconda3\Library\bin 目录。
conda list anaconda$
# packages in environment at C:\Users\Evgeni\Anaconda3:
#
# Name Version Build Channel
anaconda custom py37_0
我做了什么:
conda create -n py27 python=2.7
activate py27
conda install ipykernel
source deactivate
然后我启动了 Jupyter Notebook,没有可用的 Python 2.7 内核。我想查看内核列表,但收到错误:
jupyter kernelspec
Traceback (most recent call last):
File "C:\Users\Evgeni\Anaconda3\Scripts\jupyter-kernelspec-script.py", line 6, in <module>
from jupyter_client.kernelspecapp import KernelSpecApp
File "C:\Users\Evgeni\Anaconda3\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
from .connect import *
File "C:\Users\Evgeni\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 281, in <module>
'hb' : zmq.REQ,
AttributeError: module 'zmq' has no attribute 'REQ'
更新型多巴胺
conda install jupyter
Collecting package metadata: done
Solving environment: /
The environment is inconsistent, please check the package plan carefully
The following packages are causing the inconsistency:
- defaults/win-64::ipykernel==5.1.0=py37h39e3cac_0
- defaults/win-64::ipywidgets==7.4.2=py37_0
- defaults/win-64::jupyter==1.0.0=py37_7
- defaults/win-64::jupyterlab==0.35.4=py37hf63ae98_0
- defaults/win-64::jupyterlab_server==0.2.0=py37_0
- defaults/win-64::jupyter_client==5.2.4=py37_0
- defaults/win-64::jupyter_console==6.0.0=py37_0
- defaults/win-64::notebook==5.7.8=py37_0
- defaults/noarch::qtconsole==4.4.4=py_0
- defaults/win-64::spyder==3.3.4=py37_0
- defaults/win-64::spyder-kernels==0.4.4=py37_0
- defaults/win-64::widgetsnbextension==3.4.2=py37_0
- defaults/win-64::_ipyw_jlab_nb_ext_conf==0.1.0=py37_0
done
## Package Plan ##
environment location: C:\Users\Evgeni\Anaconda3
added / updated specs:
- jupyter
The following NEW packages will be INSTALLED:
pyzmq pkgs/main/win-64::pyzmq-18.0.0-py37ha925a31_0
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
然后
jupyter kernelspec
又出现一个错误:
_cffi_ext.c
C:\Users\Evgeni\Anaconda3\lib\site-packages\zmq\backend\cffi\__pycache__\_cffi_ext.c(213): fatal error C1083: Cannot open include file: 'sys/un.h': No such file or directory
Traceback (most recent call last):
File "C:\Users\Evgeni\Anaconda3\Scripts\jupyter-kernelspec-script.py", line 6, in <module>
from jupyter_client.kernelspecapp import KernelSpecApp
File "C:\Users\Evgeni\Anaconda3\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
from .connect import *
File "C:\Users\Evgeni\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 23, in <module>
import zmq
File "C:\Users\Evgeni\Anaconda3\lib\site-packages\zmq\__init__.py", line 47, in <module>
from zmq import backend
File "C:\Users\Evgeni\Anaconda3\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\Users\Evgeni\Anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\Evgeni\Anaconda3\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\Users\Evgeni\Anaconda3\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\Evgeni\Anaconda3\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: DLL load failed: The specified module could not be found.
如何安装并启用 Python 2.7 内核?欢迎提供任何建议。