python包安装时的ImportError

时间:2017-03-06 19:56:23

标签: python django importerror html5lib django-wiki

我完全按照文档http://django-wiki.readthedocs.io/en/latest/installation.html

中的说明安装django-wiki

当我尝试执行' python manage.py migrate'时,我收到以下错误:

Traceback (most recent call last):                                                                                  
File "manage.py", line 13, in <module>                                                                            
  execute_from_command_line(sys.argv)                                                                             
File "/var/www/unihotel/common_apps_1/django/core/management/__init__.py", line 338, in execute_from_command_line 
  utility.execute()                                                                                               
File "/var/www/unihotel/common_apps_1/django/core/management/__init__.py", line 312, in execute                   
  django.setup()                                                                                                  
File "/var/www/unihotel/common_apps_1/django/__init__.py", line 18, in setup                                      
  apps.populate(settings.INSTALLED_APPS)                                                                          
File "/var/www/unihotel/common_apps_1/django/apps/registry.py", line 108, in populate                             
  app_config.import_models(all_models)                                                                            
File "/var/www/unihotel/common_apps_1/django/apps/config.py", line 198, in import_models                          
  self.models_module = import_module(models_module_name)                                                          
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module                                      
  __import__(name)                                                                                                
File "/usr/lib/python2.7/site-packages/wiki/models/__init__.py", line 10, in <module>                             
  from .article import *  # noqa                                                                                  
File "/usr/lib/python2.7/site-packages/wiki/models/article.py", line 14, in <module>                              
  from wiki.conf import settings                                                                                  
File "/usr/lib/python2.7/site-packages/wiki/conf/settings.py", line 3, in <module>                                
  import bleach                                                                                                   
File "/usr/lib/python2.7/site-packages/bleach/__init__.py", line 19, in <module>                                  
  from .sanitizer import BleachSanitizer                                                                          
File "/usr/lib/python2.7/site-packages/bleach/sanitizer.py", line 5, in <module>                                  
  from html5lib.constants import tokenTypes                                                                       
ImportError: cannot import name tokenTypes    

但是当我用python shell导入它时......

>>> from html5lib.constants import tokenTypes
>>> print(tokenTypes)
{u'Comment': 6, u'StartTag': 3, u'EmptyTag': 5, u'Characters': 1, u'EndTag': 4, u'ParseError': 7, u'Doctype': 0, u'SpaceCharacters': 2}

......它运作得很好。

请对此有任何帮助!

1 个答案:

答案 0 :(得分:0)

问题是word = "python" word = word[1:len(word)] + word[0] + "ay" 使用的是其他版本的manage.py而不是python解释器。检测此问题的最简单方法是直接转到导致错误的包文件,并使用html5lib打印包版本。希望这有助于某人。