python - 命令错误 : You appear not to have the 'psql' program installed or on your path

标签 python django postgresql django-settings django-database

我使用的是 Windows,没有 virtualenv。我在 Pip 上安装了 psycopg2,还安装了最新版本的 PostgreSQL。

当我运行 ./manage.py dbshel​​l 时,出现以下错误:

CommandError: You appear not to have the 'psql' program installed or on your path.

当我运行 ./manage.py dbshel​​l psql 时,我得到了这个:

usage: manage.py dbshell [-h] [--version] [-v {0,1,2,3}] [--settings SETTINGS]
                         [--pythonpath PYTHONPATH] [--traceback] [--no-color]
                         [--database DATABASE]
manage.py dbshell: error: unrecognized arguments: psql

我已经阅读了一些关于此错误的其他帖子,例如 this但我不明白为什么这对我不起作用。我已正确配置所有设置,并安装了所有正确的应用程序。

我的设置.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'postgres',
        'USER': 'postgres',
        'PASSWORD': '********',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

编辑:我没有将 Postgres 的/bin 文件夹添加到我的路径中。我刚刚做到了,它现在正在工作。感谢丹尼尔罗斯曼。

最佳答案

在 Windows 中,我通过将此添加到 PATH 环境来解决:

C:\Program Files\PostgreSQL\12\bin

然后重启终端和IDE

Path Environment PATH

How to add a folder to Path environment variable in Windows

关于python - 命令错误 : You appear not to have the 'psql' program installed or on your path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47124297/

相关文章:

python - 获取计算机硬件信息

python - 背景按钮颜色在按下时不会改变

通过 QueueHandler 的 Python 多处理日志记录

python - Rest框架如何创建可选的嵌套对象?

django-fts : How to create indexes for psql

python - 重新插入 DataFrame,使其与另一个(非常相关的)DataFrame 对齐

python - Mongoengine、flask-MongoEngine 和 Django-MongoEngine 之间的区别?

python - PicklingError : Can't pickle <class 'decimal.Decimal' >: it's not the same object as decimal. 十进制

perl - DBD::Pg 中的手动事务管理

postgresql - 序列不受事务影响?