简体   繁体   English

没有名为 psycopg2 的模块

[英]No module named psycopg2

I have Django project which uses postgresql 9. I installed psycopg2 and when I run project I receive 'Error loading psycopg2 module: dll load failed'.我有一个使用 postgresql 9 的 Django 项目。我安装了 psycopg2,当我运行项目时,我收到“加载 psycopg2 模块时出错:dll 加载失败”。 I met this issue for the first time.我第一次遇到这个问题。 I have windows 7 x64 with python2.7.我有带有 python2.7 的 Windows 7 x64。 How can I solve this one?我该如何解决这个问题?

I had the same problem, it was that psycopg2 does not install well in Windows with _easy_install_, I followed the instructions on the follow SO answer:我遇到了同样的问题, psycopg2无法在 Windows 中使用 _easy_install_ 很好地安装,我按照以下 SO 答案中的说明进行操作:

Installing psycopg2 (postgresql) in virtualenv on windows 在 windows 上的 virtualenv 中安装 psycopg2 (postgresql)

You need to manually install the psycopg2 exe file:您需要手动安装psycopg2 exe文件:

psycopg2-2.4.2.win-amd64-py2.7-pg9.0.4-release.exe psycopg2-2.4.2.win-amd64-py2.7-pg9.0.4-release.exe

I know this is going to haunt me again or as nwcell puts it:我知道这会再次困扰我,或者正如nwcell所说:

Every time I need to set up psycopg2 on windows, I wind up wanting to shoot something.每次我需要在 Windows 上设置 psycopg2 时,我都想拍摄一些东西。

I actually have a machine with it working and I've been at pains to setup another machine.我实际上有一台可以工作的机器,我一直在努力设置另一台机器。 I installed Python 3.8 and the old PC has 3.7.4.我安装了 Python 3.8,旧电脑有 3.7.4。 The main difference was the file:主要区别在于文件:

C:\\project\\venv\\Lib\\site-packages\\psycopg2_psycopg.cp37-win32.pyd C:\\project\\venv\\Lib\\site-packages\\psycopg2_psycopg.cp37-win32.pyd

On the new PC it was showing as AMD64.在新 PC 上,它显示为 AMD64。 I eventually uninstalled 3.8 and reverted back to 3.7.4, then I copied the files from the old PC to the new and then I hit this error:我最终卸载了 3.8 并恢复到 3.7.4,然后我将文件从旧 PC 复制到新 PC,然后我遇到了这个错误:

https://stackoverflow.com/a/37819509/495455 https://stackoverflow.com/a/37819509/495455

Going to a WayBackMachine version of the stickpeople:转到stickpeople的WayBackMachine版本:

https://web.archive.org/web/20191003103502/http://www.stickpeople.com/projects/python/win-psycopg/ https://web.archive.org/web/20191003103502/http://www.stickpeople.com/projects/python/win-psycopg/

I didn't install the exe, I simply did a pip install -Iv psycopg2-binary==2.8.4 at which point it started working.我没有安装 exe,我只是做了一个pip install -Iv psycopg2-binary==2.8.4 ,此时它开始工作了。 So I'm thinking the latest version doesn't work, for me 2.8.4 still works: https://pypi.org/project/psycopg2/#files所以我认为最新版本不起作用,对我来说 2.8.4 仍然有效: https : //pypi.org/project/psycopg2/#files

It's something to do with x64 as everything I tried with AMD64 didn't work and I spent ages on it.这与 x64 有关,因为我在 AMD64 上尝试的所有方法都不起作用,而且我花了很长时间在上面。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM