Django下编译项目出错,需要安装sqlite3

Django装完,创建第一个项目,并运行:python manage.py runserver。提示出错:

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

需要安装sqlite3.

SQLite3下载地址:http://www.sqlite.org/download.html

进入下载目录,解压文件tar -zxvf sqlite-amalgamation-3.7.3.tar.gz.

解压后生成sqlite-3.7.3目录. cd 进入sqlite-3.7.3。

./configure

make

sudo make install

安装完成。

2测试

在任意目录下新建一个数据库,比如student ,

命令: sqlite3 student

出现如下提示:

SQLite version 3.7.2
Enter “.help” for instructions
Enter SQL statements terminated with a “;”
sqlite>

进入python安装目录,重新make/make install。

再运行:

python manage.py runserver

ok啦:

[root@node01 DjangoTest]# python manage.py runserver
Performing system checks…

System check identified no issues (0 silenced).
March 29, 2016 - 01:40:27
Django version 1.9.1, using settings ‘DjangoTest.settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Not Found: /
[29/Mar/2016 01:40:48] “GET / HTTP/1.1” 200 1767
Not Found: /favicon.ico
[29/Mar/2016 01:40:48] “GET /favicon.ico HTTP/1.1” 404 1940
Not Found: /favicon.ico
[29/Mar/2016 01:40:48] “GET /favicon.ico HTTP/1.1” 404 1940

在浏览器界面输入:

[root@node01 DjangoTest]# python manage.py runserver
Performing system checks…

System check identified no issues (0 silenced).
March 29, 2016 - 01:40:27
Django version 1.9.1, using settings ‘DjangoTest.settings’
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Not Found: /
[29/Mar/2016 01:40:48] “GET / HTTP/1.1” 200 1767
Not Found: /favicon.ico
[29/Mar/2016 01:40:48] “GET /favicon.ico HTTP/1.1” 404 1940
Not Found: /favicon.ico
[29/Mar/2016 01:40:48] “GET /favicon.ico HTTP/1.1” 404 1940

也能看到:

猜你喜欢

转载自blog.csdn.net/weixin_43063753/article/details/86661134