简体   繁体   English

导入错误:导入 _psycopg 时 DLL 加载失败:找不到指定的模块

[英]ImportError: DLL load failed while importing _psycopg: The specified module could not be found

I have a django project that I am trying to connect with a postgres database.我有一个 django 项目,我试图将它与 postgres 数据库连接。 However when I try to run the command python manage.py makemigrations I get the following error:但是,当我尝试运行命令python manage.py makemigrations ,出现以下错误:

(card_crate_venv) G:\Shared drives\Card Crate\Software Development\card_crate_admin\website>python manage.py makemigrations
Traceback (most recent call last):
  File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\website\manage.py", line 22, in <module>
    main()
  File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\website\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\django\core\management\__init__.py", line 377, in execute
    django.setup()
  File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\django\apps\registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\lib\site-packages\django\apps\config.py", line 90, in create
    module = import_module(entry)
  File "C:\Users\Ross Waston\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "G:\Shared drives\Card Crate\Software Development\card_crate_admin\card_crate_venv\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.

settings.py:设置.py:

INSTALLED_APPS = [
    'psycopg2',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'dashboard.apps.DashboardConfig',
]

...

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'development',
        'USER': 'superuser',
        'PASSWORD': 'admin',
        'HOST': '192.168.1.100',
        'PORT': '5432',
    }
}

packages:包:

在此处输入图片说明

I found that this does not work because I was using python 3.9 as a interpreter.我发现这不起作用,因为我使用 python 3.9 作为解释器。 In PyCharm, I created a new interpreter, setting the base interpreter as python 3.7 and reinstalled all my needed packages it worked as expected在 PyCharm 中,我创建了一个新的解释器,将基本解释器设置为 python 3.7 并重新安装了我需要的所有包,它按预期工作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 加载 psycopg2 模块时出错:导入 _psycopg 时 DLL 加载失败:找不到指定的模块 - Error loading psycopg2 module: DLL load failed while importing _psycopg: The specified module could not be found 导入 Cartopy 时 ImportError: DLL load failed while importing trace: The specified module could not be found - When importing Cartopy ImportError: DLL load failed while importing trace: The specified module could not be found 导入 Dash 时出错:“ImportError: DLL load failed while importing _brotli: The specified module could not be found.” - Error when importing Dash: "ImportError: DLL load failed while importing _brotli: The specified module could not be found." Django postgres 数据库连接 - DLL 在导入 _psycopg 时加载失败:找不到指定的模块 - Django postgres database connectivity - DLL load failed while importing _psycopg: The specified module could not be found cx_Freeze ImportError: DLL load failed while importing _ctypes: 找不到指定的模块 - cx_Freeze ImportError: DLL load failed failed while importing _ctypes: The specified module could not be found (ibm_db) ImportError: DLL load failed while importing ibm_db: The specified module could not be found - (ibm_db) ImportError: DLL load failed while importing ibm_db: The specified module could not be found 导入错误:导入 _openmp_helpers 时 DLL 加载失败:找不到指定的模块 - ImportError: DLL load failed while importing _openmp_helpers: The specified module could not be found ImportError: DLL load failed while importing pymqe: The specified module could not be found - ImportError: DLL load failed while importing pymqe: The specified module could not be found 在pycharm ImportError中:DLL加载失败:找不到指定的模块。 导入人脸识别时 - In pycharm ImportError: DLL load failed: The specified module could not be found. while importing facerecognition ImportError: DLL 在导入 cv2 时加载失败:在 pycharm 中找不到指定的模块,python 3.9 - ImportError: DLL load failed while importing cv2: The specified module could not be found in pycharm with python 3.9
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM