ModuleNotFoundError : 没有名为“psycopg2._psycopg"的模块 [英] ModuleNotFoundError : No module named 'psycopg2._psycopg'
问题描述
我正在使用进口:-导入psycopg2
但是在本地运行代码时,我面临一个问题:-
But while running the code in local, I am facing an issue of :-
从 psycopg2._psycopg 导入 (
ModuleNotFoundError:没有名为psycopg2._psycopg"的模块
我已经使用 cmd [pip install psycopg2] 安装了 psycopg2psycopg2 版本 2.8.4蟒蛇版本 3.7.3python 3.7 32位
I have installed psycopg2 using cmd [pip install psycopg2] psycopg2 version 2.8.4 python version 3.7.3 python 3.7 32bit
我应该如何在 Windows 中导入 ._psycopg.py 文件?或者任何其他可能的解决方案?
How should I import the ._psycopg.py file in windows? or any other solution if possible?
推荐答案
我也面临同样的问题.我花了 2 天的时间拔掉头发,直到找到解决方案.
I'm also facing the same problem. It took me 2 days to pulled out my hair until I found the solution.
这是我一直在做的事情来解决这个问题但没有解决问题.我希望它可以帮助其他有同样问题的人.
Here's what I have been doing to solve this issue BUT DIDN'T SOLVE THE PROBLEM. I hope it will help anybody else who has the same problem.
- 安装psycopg2"和psycopg2-二进制"
pip install psycopg2
pip install psycopg2-binary
sudo apt install libpq-dev
sudo apt install python-psycopg2 python3-psycopg2
sudo apt install python-dev python3-dev python3.9-dev
sudo apt install python-setuptools
不幸的是,我的上述努力都没有解决我的问题.
Unfortunately, none of my effort above solve my problem.
所以,这是我尝试过的解决方案,IT 有效
So, here's my solution that I've been try and IT WORKS
从 Github 安装最新的 mod_wsgi.
您应该安装最新的mod_wsgi",以便您的 wsgi 能够使用 Psycopg2 库.这是我的步骤:
You should install this latest 'mod_wsgi' in order to your wsgi able to use Psycopg2 library. Here's my step to do it :
- 转到 Github 上的发布页面 mod_wsgi (https://github.com/GrahamDumpleton/mod_wsgi/releases)
- 从最新版本下载文件.在我写这篇文章时,最新版本是 4.7.1 (https://github.com/GrahamDumpleton/mod_wsgi/archive/4.7.1.tar.gz)
- 按照官方文档中的安装指南进行操作.
- Go to release page mod_wsgi on Github (https://github.com/GrahamDumpleton/mod_wsgi/releases)
- Download the file from latest version. As I write this, the latest version is 4.7.1 (https://github.com/GrahamDumpleton/mod_wsgi/archive/4.7.1.tar.gz)
- Follow the installation guide from official docs.
- 拆包源代码
tar xvfz mod_wsgi-4.7.1.tar.gz
./configure
制作
进行安装
sudo service apache2 restart
此解决方案适用于我的机器(Ubuntu 18.04 和 Python 3.9 Venv).
This solution has works on my machine (Ubuntu 18.04 & Python 3.9 Venv).
这是其他人的一些解决方案.
Here's some solution from others.
这篇关于ModuleNotFoundError : 没有名为“psycopg2._psycopg"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!