Jupyter Notebook from command line - ImportError - cannot import name 'TYPE'

夙愿已清 提交于 2020-01-06 04:45:06

问题


Traceback (most recent call last):
  File "/Users/codymitchell/Documents/code/py/zipline/venv/bin/jupyter-notebook", line 6, in <module>
    from notebook.notebookapp import main
  File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/notebook/__init__.py", line 25, in <module>
    from .nbextensions import install_nbextension
  File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/notebook/nbextensions.py", line 610, in <module>
    from .extensions import (
  File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/notebook/extensions.py", line 8, in <module>
    from tornado.log import LogFormatter
  File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/tornado/log.py", line 34, in <module>
    from tornado.escape import _unicode
  File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/tornado/escape.py", line 27, in <module>
    from tornado.util import unicode_type
  File "/Users/codymitchell/Documents/code/py/zipline/venv/lib/python3.5/site-packages/tornado/util.py", line 21, in <module>
    from typing import (
ImportError: cannot import name 'Type'

回答1:


I had the same issue, here's how I solved it

Python 3.5.1 doesn't have typing.Type

https://github.com/django-extensions/django-extensions/issues/1188

C:\Users\rigupta>D:\Anaconda3\python
Python 3.5.1 |Anaconda 4.0.0 (64-bit)| (default, Feb 16 2016, 09:49:46) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import typing
>>> typing.Type
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'typing' has no attribute 'Type'
>>> typing.type
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'typing' has no attribute 'type'
>>>

so I upgraded my python version to 3.5.4 by running below command which resolved the issue

conda update --all

https://www.youtube.com/watch?v=Q-dZCAk1tfc




回答2:


I had the exact same problem. I am running windows 7 64-bit, running on Portable Python 3.7.3.

When Jupyter was failing, I was running Portable Python at this path:

E:\applications\python37\Portable Python-3.7.3\App\Python

Uninstalling and reinstalling Jupyter, typing modules did not solve the problem.

I was suspicions of problematic path-names, so I copied the python installation to a path without whitespaces (and maybe a shorter path?):

E:\applications\python37\Python

Finally, I managed to get Jupyter Notebook to work!



来源:https://stackoverflow.com/questions/55274029/jupyter-notebook-from-command-line-importerror-cannot-import-name-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!