问题
I am a Windows user, and I have installed Python 3.6 on my computer. In order to use Jupyter notebooks, I downloaded atom. I already installed ipython and pandas. After entering the command jupyter notebook on the command-line, my browser doesn't open jupyter notebook, instead I get the follow error message:
[C:\Users\ELIDAD>jupyter notebook
Traceback (most recent call last):
File "c:\users\elidad\appdata\local\programs\python\python35\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\elidad\appdata\local\programs\python\python35\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\ELIDAD\AppData\Local\Programs\Python\Python35\Scripts\jupyter-notebook.EXE\__main__.py", line 5, in <module>
File "c:\users\elidad\appdata\local\programs\python\python35\lib\site-packages\notebook\__init__.py", line 25, in <module>
from .nbextensions import install_nbextension
File "c:\users\elidad\appdata\local\programs\python\python35\lib\site-packages\notebook\nbextensions.py", line 610, in <module>
from .extensions import (
File "c:\users\elidad\appdata\local\programs\python\python35\lib\site-packages\notebook\extensions.py", line 8, in <module>
from tornado.log import LogFormatter
File "c:\users\elidad\appdata\local\programs\python\python35\lib\site-packages\tornado\log.py", line 34, in <module>
from tornado.escape import _unicode
File "c:\users\elidad\appdata\local\programs\python\python35\lib\site-packages\tornado\escape.py", line 27, in <module>
from tornado.util import unicode_type
File "c:\users\elidad\appdata\local\programs\python\python35\lib\site-packages\tornado\util.py", line 21, in <module>
from typing import (
ImportError: cannot import name 'Type']
So, what is the problem? I am new to python and jupyter notebook. Thank you very much.
回答1:
Install anaconda ,
"Anaconda is a free and open-source distribution of the Python and R programming languages for scientific computing, that aims to simplify package management and deployment " (As on google)
and then try Jupyter notebook link: https://www.anaconda.com/distribution/
回答2:
It is because Python3.5 has its own version typing (https://docs.python.org/3/library/typing.html), and it is incompatible with the installed version of jupyter/tornado Upgrade to python3.6 could solve the problem.
回答3:
Since the error seems to come from the tornado package, i would try to reinstall tornado if this does not help I made the experience that the conda packages often work better in windows: so just reinstall jupyter notebook (best in a new env) using anaconda
Best of luck, installing jupyter notebook used to make me a lot of troubles as well.
回答4:
If you're using Python 3.5.1 and don't want to use Conda, downgrading the Tornado version allows it run. Current Tornado version is 6.0.3. I downgraded it 4.5.1 because I knew it worked. Other versions after this might also work. It's an easy fix without the need to update the Python version.
回答5:
I think it will be better to create a virtual environment. Then, re-install jupyter notebook under that environment.
Visit https://www.digitalocean.com/community/tutorials/how-to-set-up-jupyter-notebook-with-python-3-on-ubuntu-18-04
回答6:
Python 3.5.1 doesn't have typing.Type, so I upgraded my python version to 3.5.4 which did the trick, for more details, Please check below link
https://stackoverflow.com/a/56159851/7741962
回答7:
This happens because python 3.5+ has own typing and that doesn't have Deque class. You can do one thing, in protocol.py remove Deque from the import state and import Deque from collections
回答8:
If you want to get rid of the error
ImportError: cannot import name 'Type']
Just upgrade or use Python 3.5.4 that will solve the issue.
来源:https://stackoverflow.com/questions/55210213/jupyter-notebook-importerror-cannot-import-name-type