(Python)psycopg2安装 [英] (Python) psycopg2 installation
问题描述
我对Python的使用经验很少,并且陷入了应该是一个非常简单的问题上.我在Mac上使用Jupyter Notebook.
I have a fairly light amount of experience with Python and got stuck on what should be a pretty simple issue. I am using Jupyter Notebook on a Mac.
我想在Python中安装psycopg2,所以我输入
I wanted to install psycopg2 in Python so I typed in
import psycopg2 as pg2
但是,我遇到了以下错误:
But, I got the following error:
ModuleNotFoundError Traceback (most recent call
last)
<ipython-input-1-32fa0c891bdd> in <module>
----> 1 import psycopg2 as pg2
ModuleNotFoundError: No module named 'psycopg2'
然后我去航站楼并输入:
I then went over to the terminal and typed in:
pip install psycopg2
这导致了另一个错误:
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the
directory
containing pg_config to the $PATH or specify the full executable path
with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
我不确定如何在错误消息中使用此信息.有人可以帮我指出正确的方向吗?
I'm not sure how to go about using this information in the error message. Can someone help point me in the right direction?
还可以跟进问题:
a.)为什么我不必对pandas或numpy进行配置时,为什么需要在终端中使用pip install modulename?
a.) Why would I need to use pip install modulename in the terminal when I don't have to do that with either pandas or numpy?
任何帮助将不胜感激.
推荐答案
请尝试安装psycopg2-binary,因为您可能没有在计算机上安装所有C库依赖项.
pip install psycopg2-binary
Please try installing psycopg2-binary as you probaly do not have all the C library dependencies installed on your computer.
pip install psycopg2-binary
这篇关于(Python)psycopg2安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!