【问题标题】:CommandError: You appear not to have the 'psql' program installed or on your pathCommandError:您似乎没有安装“psql”程序或在您的路径上
【发布时间】:2018-04-17 20:52:03
【问题描述】:

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

当我运行./ manage.py dbshell 时,我收到以下错误:

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

当我运行 ./ manage.py dbshell 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 文件夹添加到我的 PATH 中。我刚刚做到了,它现在正在工作。感谢丹尼尔·罗斯曼。

【问题讨论】:

  • 嗯,它在你的路上吗?如果你只运行 psql 会发生什么?
  • 在更新 PATH 环境变量以反映更改后,不要忘记重新启动命令提示符。
  • @Valachio 你最后是怎么解决的??

标签: django postgresql django-settings django-database


【解决方案1】:

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

C:\Program Files\PostgreSQL\12\bin

然后重启终端和IDE

Path Environment PATH

How to add a folder to Path environment variable in Windows

【讨论】:

    【解决方案2】:

    对于 mac,运行命令brew install postgres

    如果您的机器没有安装 brew,请按照this 安装 brew。或者运行命令

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
    

    【讨论】:

      【解决方案3】:

      你的机器上是否安装了 postgresql。

      除了:

      pip install psycopg2
      

      你需要安装 postgres:

      sudo apt-get install postgres
      

      【讨论】:

        猜你喜欢
        • 2017-03-15
        • 2016-09-14
        • 2018-08-03
        • 1970-01-01
        • 2018-09-12
        • 1970-01-01
        • 1970-01-01
        • 2020-04-10
        • 2019-01-11
        相关资源
        最近更新 更多