gpt4 book ai didi

Django - 没有名为 _sqlite3 的模块

转载 作者:IT王子 更新时间:2023-10-29 06:17:58 25 4
gpt4 key购买 nike

我在我的 rhel 5 上安装了 django 1.4。默认情况下,rhel 5 中有 python 2.4,但是为了使用 django 1.4,我手动安装了 python 2.7.3开发服务器运行良好,但是当我创建一个新项目并将 settings.py 文件更改为:

'ENGINE': 'django.db.backends.sqlite3','NAME': '/home/oracle/Desktop/test1/my.db'

现在当我给 python2.7 manage.py syncdb 命令时,我得到的错误是:

Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 443, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py",
line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py",
line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py",
line 8, in <module>
from django.core.management.sql import custom_sql_for_model,
emit_post_sync_signal
File "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py",
line 6, in <module>
from django.db import models
File "/usr/local/lib/python2.7/site-packages/django/db/__init__.py",
line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/usr/local/lib/python2.7/site-packages/django/db/__init__.py",
line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/usr/local/lib/python2.7/site-packages/django/db/utils.py",
line 92, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python2.7/site-packages/django/db/utils.py",
line 24, in load_backend
return import_module('.base', backend_name)
File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py",
line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py",
line 31, in <module>
raise ImproperlyConfigured("Error loading either pysqlite2 or
sqlite3 modules (tried in that order): %s" % exc)
django.core.exceptions.ImproperlyConfigured: Error loading either
pysqlite2 or sqlite3 modules (tried in that order): No module named
_sqlite3

请指出出路?

最佳答案

你也可能在没有安装sqlite开发库的情况下手动编译了python

所以,做

sudo apt-get install libsqlite3-dev libsqlite3

然后,重新安装python

输入测试

python
>>> import sqlite3

关于Django - 没有名为 _sqlite3 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10784132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com