相关疑难解决方法(0)

如何查找pg_config路径

在这里完成新手,试图设置Django与ProstgreSQL一起工作.

我正在使用mac osx 10.6.8.我还安装了PostgreSQL 9.3

当我pip install psycopg2在终端运行时,我收到以下错误

Downloading/unpacking psycopg2
  Downloading psycopg2-2.5.2.tar.gz (685kB): 685kB downloaded
  Running setup.py (path:/private/var/folders/A9/A99cs6x0FNusPejCVkYNTE+++TI/-Tmp-/pip_build_bengorman/psycopg2/setup.py) egg_info for package psycopg2

    Error: pg_config executable not found.

    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 ...

    or with the pg_config option in 'setup.cfg'.
    Complete output from command python setup.py egg_info:
    running egg_info

creating pip-egg-info/psycopg2.egg-info

writing pip-egg-info/psycopg2.egg-info/PKG-INFO

writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt

writing …
Run Code Online (Sandbox Code Playgroud)

python django postgresql macos

62
推荐指数
9
解决办法
9万
查看次数

尝试在OS X中使用virtualenv启动Python时出现"非法指令:4"

我已经在一个virtualenv环境中使用Python 2.7.10 几个月了.

昨天,激活环境很顺利,但是今天突然间我在尝试从终端启动Python时遇到了这个神秘的错误:

Illegal instruction: 4

我没有改变我的环境(AFAIK),所以我很难尝试解决这个错误是什么以及导致它的原因.

Python在这种virtualenv环境之外工作正常.通过/usr/local/bin它运行时没有问题.

macos virtualenv python-2.7

6
推荐指数
1
解决办法
2971
查看次数

高Sierra + Python + Postgresql错误:非法指令:4

我可以通过命令行连接到Postgres没问题,但是如果我尝试使用psycopg2模块通过Python连接,我会收到以下错误.有趣的是,我刚刚尝试连接PSeqal.app,它崩溃了同样的错误.

环境:

  • MacOS:10.13.3
  • Xcode 9.2
  • Python:3.6.4
    • 连接模块:psycopg2
  • Postgresql:10.3

脚本:

这是我的简单连接脚本,它试图通过Python连接到Postgresql:

def connect(self, params):
    """ Connect to the PostgreSQL database server """

    conn = None
    try:
        # connect to the PostgreSQL server
        logging.info('Connecting to the PostgreSQL database...')
        conn = psycopg2.connect(**params)

        # create a cursor
        self.cursor = conn.cursor()

        except (Exception, psycopg2.DatabaseError) as error:
            print(error)
        finally:
            if conn is not None:
                conn.close()
                logging.warning('Database connection closed.')
Run Code Online (Sandbox Code Playgroud)

错误:

脚本输出:

$ python3 testdb.py
非法指令:4

Apple错误(部分):

Process:               Python [79534]
Path:                  /usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python
Identifier:            Python
Version:               3.6.4 (3.6.4)
Code …
Run Code Online (Sandbox Code Playgroud)

python postgresql macos psycopg2 python-3.x

5
推荐指数
1
解决办法
858
查看次数