我使用的是导入:- import psycopg2
但在本地运行代码时,我面临的问题是:-
从psycopg2._psycopg导入( )
ModuleNotFoundError:没有名为“psycopg2._psycopg”的模块
我已经使用cmd pip安装了psycopg2,psycopg2 psycopg2版本2.8.4 pythonVersion3.7.3 python3.7 32位
如何在windows中导入._psycopg.py文件?如果可能的话还有其他解决办法吗?
发布于 2020-11-13 07:56:07
我也面临着同样的问题。我花了两天才拔出头发,直到找到解决办法。
我被试过的
下面是我为解决这个问题所做的事情,,但没有解决问题,。我希望这会对其他有同样问题的人有所帮助。
pip install psycopg2pip install psycopg2-binarysudo apt install libpq-devsudo apt install python-psycopg2 python3-psycopg2sudo apt install python-dev python3-dev python3.9-devsudo apt install python-setuptools不幸的是,我以上的努力都解决不了我的问题。
解决办法是什么
所以,下面是我一直在尝试的解决方案,IT WORKS
从Github.安装最新的mod_wsgi
您应该安装这个最新的“mod_wsgi”,以便您的Psycopg2库能够使用。这是我要做的一步:
tar xvfz mod_wsgi-4.7.1.tar.gz1. [Configure source code](https://modwsgi.readthedocs.io/en/latest/user-guides/quick-installation-guide.html#configuring-the-source-code)
- `./configure`1. [Build the source code and install](https://modwsgi.readthedocs.io/en/latest/user-guides/quick-installation-guide.html#building-the-source-code)
- `make`
- `make install`1. [Restart apache server](https://modwsgi.readthedocs.io/en/latest/user-guides/quick-installation-guide.html#restart-apache-web-server)
- `sudo service apache2 restart`这个解决方案可以在我的机器上工作(Ubuntu18.04&Python3.9Venv)。
替代解
这是来自其他人的一些解决方案。
https://stackoverflow.com/questions/61006302
复制相似问题