目的:使用psycopg2模块连接postgre数据库
方法:
1.通过pip安装
S1:直接输入pip3 install psycopg2会报错如下:
>>>
Traceback (most recent call last):
File "D:\Program Files\anaconda3\Scripts\pip3-script.py", line 6, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
S2:通过搜索报错内容,在命令提示符输入:python -m ensurepip 解决。
参考网址:https://blog.csdn.net/a1007720052/article/details/81906460
S3:再次输入S1命令,提示升级pip
>>>
WARNING: You are using pip version 20.1.1; however, version 20.3.1 is available.
You should consider upgrading via the 'd:\program files\anaconda3\python.exe -m pip install --upgrade pip' command.
S4:按提示输入python.exe -m pip install --upgrade pip
S5:再次输入:pip3 install psycopg2
OK。
2.方法2:在conda客户端-environments-搜索安装(搜索结果显示花了点时间,以为不成功,所以尝试了方法1,后来发现成功搜索到。)