Django postgres数据库连接 - 导入_psycopg时DLL加载失败:找不到指定的模块。

问题描述 投票:0回答:1

我已经尝试了许多可用的选项,但是没有任何工作适合我。

这是我的环境

  • 操作系统 : Windows 10 Home 64bit
  • Python版本:Python 3.9.0a6。
  • Django版本 : 3.0.5
  • Postgress数据库版本:12

这是我用来做连接的方法。

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'xxxx',
        'USER': 'postgres',
        'PASSWORD': 'admin',
        'HOST': 'localhost'
    }
}

错误 我收到的。

(dev-test) F:\Personal\xxxx\Learning\Django\projects\jangoproject\devtest>python manage.py startserver
Traceback (most recent call last):
  File "C:\Users\LENOVO\Envs\dev-test\lib\site-packages\django\db\backends\postgresql\base.py", line 25, in <module>
    import psycopg2 as Database
  File "C:\Users\LENOVO\Envs\dev-test\lib\site-packages\psycopg2\__init__.py", line 51, in <module>
    from psycopg2._psycopg import (                     # noqa
ImportError: DLL load failed while importing _psycopg: The specified module could not be found.

During handling of the above exception, another exception occurred:
python django postgresql
1个回答
1
投票

你可以尝试使用以下命令

pip install django psycopg2 
'ENGINE' : 'django.db.backends.postgresql_psycopg2',
'PORT'  : ' ' 

所以选择了默认端口

© www.soinside.com 2019 - 2024. All rights reserved.