解决No module named _sqlite3的问题

前端之家收集整理的这篇文章主要介绍了解决No module named _sqlite3的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在linux机器上,运行django执行新建app命令python manage.py startapp learn,报错:

No module named _sqlite3


详细错误如下:

[python] view plain copy
  1. #pythonmanage.pystartapplearn
  2. Traceback(mostrecentcalllast):
  3. File"manage.py",line10,in<module>
  4. execute_from_command_line(sys.argv)
  5. File"/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",line353,153);background-color:inherit;font-weight:bold;">inexecute_from_command_line
  6. utility.execute()
  7. 327,153);background-color:inherit;font-weight:bold;">inexecute
  8. django.setup()
  9. File"/usr/local/lib/python2.7/site-packages/django/__init__.py",line18,153);background-color:inherit;font-weight:bold;">insetup
  10. apps.populate(settings.INSTALLED_APPS)
  11. File"/usr/local/lib/python2.7/site-packages/django/apps/registry.py",line108,153);background-color:inherit;font-weight:bold;">inpopulate
  12. app_config.import_models(all_models)
  13. File"/usr/local/lib/python2.7/site-packages/django/apps/config.py",line202,153);background-color:inherit;font-weight:bold;">inimport_models
  14. self.models_module=import_module(models_module_name)
  15. File"/usr/local/lib/python2.7/importlib/__init__.py",line37,153);background-color:inherit;font-weight:bold;">inimport_module
  16. __import__(name)
  17. File"/usr/local/lib/python2.7/site-packages/django/contrib/auth/models.py",line4,248);line-height:18px;list-style-position:outside;">fromdjango.contrib.auth.base_userimportAbstractBaseUser,BaseUserManager
  18. File"/usr/local/lib/python2.7/site-packages/django/contrib/auth/base_user.py",line49,153);background-color:inherit;font-weight:bold;">classAbstractBaseUser(models.Model):
  19. File"/usr/local/lib/python2.7/site-packages/django/db/models/base.py",153);background-color:inherit;font-weight:bold;">in__new__
  20. new_class.add_to_class('_Meta',Options(Meta,app_label))
  21. 299,153);background-color:inherit;font-weight:bold;">inadd_to_class
  22. value.contribute_to_class(cls,name)
  23. File"/usr/local/lib/python2.7/site-packages/django/db/models/options.py",line263,153);background-color:inherit;font-weight:bold;">incontribute_to_class
  24. self.db_table=truncate_name(self.db_table,connection.ops.max_name_length())
  25. File"/usr/local/lib/python2.7/site-packages/django/db/__init__.py",line36,153);background-color:inherit;font-weight:bold;">in__getattr__
  26. returngetattr(connections[DEFAULT_DB_ALIAS],item)
  27. File"/usr/local/lib/python2.7/site-packages/django/db/utils.py",line212,153);background-color:inherit;font-weight:bold;">in__getitem__
  28. backend=load_backend(db['ENGINE'])
  29. 116,153);background-color:inherit;font-weight:bold;">inload_backend
  30. returnimport_module('%s.base'%backend_name)
  31. File"/usr/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py",line39,153);background-color:inherit;font-weight:bold;">raiseImproperlyConfigured("Errorloadingeitherpysqlite2orsqlite3modules(triedinthatorder):%s"%exc)
  32. django.core.exceptions.ImproperlyConfigured:Errorloadingeitherpysqlite2orsqlite3modules(triedinthatorder):Nomodulenamed_sqlite3


解决

1,首先安装 sqlite-devel

yum install sqlite-devel

2,重新编译安装Python

./configure

make

make install

猜你在找的Sqlite相关文章