python manage.py dbshel​​l尽管已安装且在路径中,但找不到psycopg2 [英] python manage.py dbshell doesn't find psycopg2 although it is installed and in path

查看:176
本文介绍了python manage.py dbshel​​l尽管已安装且在路径中,但找不到psycopg2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过python manage.py dbshel​​l发出SQL命令,但收到错误消息 CommandError:您似乎没有在路径上安装'sqlite3'程序。从python提示符下,我可以导入psycopg2而不会出现任何错误,并且psycopg2似乎在我的python路径中。



我正在尝试django并且我的settings.py指定为 ENGINE :

任何帮助将不胜感激,



谢谢,朱利安(Julian)

解决方案

当您运行 ./ manage.py dbshel​​l psql或sqlite3 此命令假定程序位于您的 PATH 上。



sqlite3



来自Python本身不包含 sqlite3 命令。如果要从命令行访问,则必须安装SQLite库,该库包含名为 sqlite3 简单命令行实用程序>。但是无需安装库就可以创建数据库服务器,因为它不需要运行单独的服务器,而sqlite3本身不需要基于文本的文件。



如果您正在开发一个简单的项目,或您不打算在生产环境中部署的内容,然后在您的情况下,首先使用 SQLite



使用 sudo apt-get install sqlite3 libsqlite3-dev 来访问dbshel​​l的sqlite3。



postgres



sqlite3 相比,此 postgres 需要打包到初始化。 postgresql需要 postgresql_psycopg2


I'd like to be issuing SQL commands via python manage.py dbshell but I get the error "CommandError: You appear not to have the 'sqlite3' program installed or on your path". From the python prompt I can import psycopg2 without getting any errors and psycopg2 appears to be in my python path.

I'm trying django and my settings.py specifies "ENGINE": "django.db.backends.postgresql_psycopg2"

Any help would be greatly appreciated,

Thanks, Julian

解决方案

when you run ./manage.py dbshell psql or sqlite3 this command assumes the programs are on your PATH. this will simply calls the program name.

sqlite3

from Python itself dosen't contain a sqlite3 command. if you want to access from the command line you have to install SQLite library that includes a simple command-line utility named sqlite3. but without installing library you can create the db server because it doesn’t require running a separate server and sqlite3 itself a text based file.

If you are developing a simple project or something you don’t plan to deploy in a production environment, then use SQLite

in your case first install sqlite3 using sudo apt-get install sqlite3 libsqlite3-dev to access dbshell.

postgres

compare to sqlite3 this postgres needs package to initialize. postgresql need postgresql_psycopg2 package

这篇关于python manage.py dbshel​​l尽管已安装且在路径中,但找不到psycopg2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆