0

过去几天我一直被这个问题困扰,这使我无法正确设置本地环境。这是我的设置:

  • 使用 OS X 10.8 山狮
  • 通过自制软件,我安装了 Python 和 PostgreSQL。
  • 在 Virtualenv 中,我通过 PIP 安装了带有 psycopg2 2.4.5 的 Django
  • 我已经验证我可以通过 pgAdmin3 连接到我的 PostgreSQL 数据库

然而,每当我启动我的 Apache 服务器并导航到我的本地 URL 时,我都会遇到这个丑陋的错误:

dlopen({....}/lib/python2.7/site-packages/psycopg2/_psycopg.so, 2): 
Symbol not found: _PyMemoryView_Type

Referenced from: {....}/lib/python2.7/site-packages/psycopg2/_psycopg.so
Expected in: flat namespace in {....}/lib/python2.7/site-packages/psycopg2/_psycopg.so

以下是我安装 psycopg2 时的结果:

Downloading/unpacking psycopg2
  Downloading psycopg2-2.4.5.tar.gz (719Kb): 719Kb downloaded
  Running setup.py egg_info for package psycopg2

    no previously-included directories found matching 'doc/src/_build'
Installing collected packages: psycopg2
  Running setup.py install for psycopg2
    building 'psycopg2._psycopg' extension
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/psycopgmodule.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/green.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/green.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/pqpath.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/pqpath.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/utils.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/utils.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/bytes_format.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/bytes_format.o
    In file included from psycopg/bytes_format.c:81:
    In file included from ./psycopg/psycopg.h:33:
    ./psycopg/config.h:71:13: warning: unused function 'Dprintf' [-Wunused-function]
    static void Dprintf(const char *fmt, ...) {}
                ^
    1 warning generated.
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/connection_int.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/connection_int.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/connection_type.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/connection_type.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/cursor_int.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/cursor_int.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/cursor_type.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/cursor_type.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/lobject_int.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/lobject_int.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/lobject_type.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/lobject_type.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/notify_type.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/notify_type.o
    In file included from psycopg/notify_type.c:27:
    In file included from ./psycopg/psycopg.h:33:
    ./psycopg/config.h:71:13: warning: unused function 'Dprintf' [-Wunused-function]
    static void Dprintf(const char *fmt, ...) {}
                ^
    1 warning generated.
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/xid_type.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/xid_type.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/adapter_asis.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_asis.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/adapter_binary.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_binary.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/adapter_datetime.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_datetime.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/adapter_list.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_list.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/adapter_pboolean.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_pboolean.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/adapter_pdecimal.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_pdecimal.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/adapter_pint.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_pint.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/adapter_pfloat.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_pfloat.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/adapter_qstring.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_qstring.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/microprotocols.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/microprotocols.o
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/microprotocols_proto.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/microprotocols_proto.o
    In file included from psycopg/microprotocols_proto.c:27:
    In file included from ./psycopg/psycopg.h:33:
    ./psycopg/config.h:71:13: warning: unused function 'Dprintf' [-Wunused-function]
    static void Dprintf(const char *fmt, ...) {}
                ^
    1 warning generated.
    /usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -Os -pipe -march=native -mmacosx-version-min=10.8 -Wno-unused-value -Wno-empty-body -Qunused-arguments -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch x86_64 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.5 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090104 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/local/Cellar/postgresql/9.1.4/include -I/usr/local/Cellar/postgresql/9.1.4/include/server -c psycopg/typecast.c -o build/temp.macosx-10.8-x86_64-2.7/psycopg/typecast.o
    In file included from psycopg/typecast.c:179:
    ./psycopg/typecast_array.c:227:31: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
                if (--stack_index < 0)
                    ~~~~~~~~~~~~~ ^ ~
    1 warning generated.
    /usr/bin/clang -bundle -undefined dynamic_lookup -L/usr/local/Cellar/readline/6.2.4/lib -L/usr/local/Cellar/gettext/0.18.1.1/lib -L/usr/local/lib -L/opt/X11/lib -arch x86_64 build/temp.macosx-10.8-x86_64-2.7/psycopg/psycopgmodule.o build/temp.macosx-10.8-x86_64-2.7/psycopg/green.o build/temp.macosx-10.8-x86_64-2.7/psycopg/pqpath.o build/temp.macosx-10.8-x86_64-2.7/psycopg/utils.o build/temp.macosx-10.8-x86_64-2.7/psycopg/bytes_format.o build/temp.macosx-10.8-x86_64-2.7/psycopg/connection_int.o build/temp.macosx-10.8-x86_64-2.7/psycopg/connection_type.o build/temp.macosx-10.8-x86_64-2.7/psycopg/cursor_int.o build/temp.macosx-10.8-x86_64-2.7/psycopg/cursor_type.o build/temp.macosx-10.8-x86_64-2.7/psycopg/lobject_int.o build/temp.macosx-10.8-x86_64-2.7/psycopg/lobject_type.o build/temp.macosx-10.8-x86_64-2.7/psycopg/notify_type.o build/temp.macosx-10.8-x86_64-2.7/psycopg/xid_type.o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_asis.o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_binary.o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_datetime.o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_list.o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_pboolean.o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_pdecimal.o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_pint.o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_pfloat.o build/temp.macosx-10.8-x86_64-2.7/psycopg/adapter_qstring.o build/temp.macosx-10.8-x86_64-2.7/psycopg/microprotocols.o build/temp.macosx-10.8-x86_64-2.7/psycopg/microprotocols_proto.o build/temp.macosx-10.8-x86_64-2.7/psycopg/typecast.o -L/usr/local/Cellar/postgresql/9.1.4/lib -lpq -lssl -lcrypto -o build/lib.macosx-10.8-x86_64-2.7/psycopg2/_psycopg.so

    no previously-included directories found matching 'doc/src/_build'
Successfully installed psycopg2

关于可能导致这种情况的任何想法?我被难住了,迫切需要一些帮助。提前致谢。让我知道是否有更多信息会有所帮助。


这是我的 Apache 虚拟主机文件:

NameVirtualHost *:80

<VirtualHost mysite.local:80>
    ServerName mysite.local

    Alias /assets/ {...}/app/webapp/assets/
    Alias /static/ {...}/lib/python2.7/site-packages/django/contrib/admin/static/
    Alias /robots.txt {...}/app/webapp/assets/robots.txt
    Alias /favicon.ico {...}/app/webapp/assets/favicon.ico

    CustomLog "{...}/logs/apache-access.log" combined
    ErrorLog "{...}/logs/apache-error.log"
    LogLevel warn

    WSGIDaemonProcess mysite.local processes=1 threads=1 maximum-requests=1 python-path={...}/lib/python2.7/site-packages python-eggs={...}/lib/python2.7/site-packages
    WSGIProcessGroup mysite.local
    WSGIScriptAlias / {...}/conf/apache/django.wsgi
    WSGIPassAuthorization On

    <Directory {...}/app/webapp/assets>
    Order deny,allow
    Allow from all
    Options -Indexes FollowSymLinks
    </Directory>

    <Directory {...}/conf/apache>
    Order deny,allow
    Allow from all
    </Directory>
</VirtualHost>

这是我的 django.wsgi 文件:

import os, sys
import django.core.handlers.wsgi
import site

sys.path.append('{...}/lib/python2.7/site-packages')
sys.path.append('{...}/app')
sys.path.append('{...}/app/webapp')
sys.path.append('{...}/app/webapp/apps')

os.environ['DJANGO_SETTINGS_MODULE'] = 'webapp.settings.production'

site.addsitedir('{...}/lib/python2.7/site-packages')

application = django.core.handlers.wsgi.WSGIHandler()
4

3 回答 3

0

在 MAC OSX 上为 python 编译包时看到一些 c 警告通常是标准的,因为它使用 clang 而不是 gcc。他们不应该是问题。该问题看起来像您的 WSGI HTTPD 设置。

使用 WSGI 和虚拟环境以及 WSGI,您需要确保正确设置进程环境。

看起来您需要更改 HTTPD 指令以包含您的处理环境。请参阅 WSGI 中的虚拟环境,标题为Process Environments的部分。

于 2012-08-18T11:10:47.407 回答
0

经过一天的文件和设置跳舞后,我终于弄明白了。非常感谢@BigHandsome 引导我朝着正确的方向前进。在我的 Apache httpd.conf 文件中,我使用的是 OS X 10.8 附带的 mod_wsgi.so。显然这是问题所在。我通过执行以下操作来修复它:

  1. 使用 Homebrew 安装新版本的 mod_wsgi.so ( brew install mod_wsgi)
  2. 起初,Homebrew 向我抛出了一个与 Mountain Lion 和 mod_wsgi 相关的错误。我在这个报告的问题上遵循了符号链接说明: https ://github.com/mxcl/homebrew/issues/13919
  3. 在对链接中详细说明的文件进行符号链接后,我重新做了brew install mod_wsgi并且它工作了。
  4. 我更新了我的 httpd.conf:LoadModule wsgi_module /usr/local/Cellar/mod_wsgi/3.3/libexec/mod_wsgi.so
  5. 我重新启动了 Apache2(apachectl restart),瞧!
于 2012-08-19T05:15:19.083 回答
0

这也困扰着我。确保你已经为正确版本的 python 构建了 mod_wsgi。

原来我已经为 python2.6 构建了 mod_wsgi,但是运行该网站的 virtualenv 使用的是 python2.7。我正在使用 macports,所以以下内容对我有用:

sudo port uninstall mod_wsgi
sudo port install mod_wsgi +python2.7

然后重启apache。

OS X 10.7.3 w/MacPorts

当 Apache 开始查看您使用的 Python 版本时,请查看 error.log 中的以下行:

[notice] Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/1.0.1e DAV/2 mod_wsgi/3.3 Python/2.7.5 configured -- resuming normal operations
于 2013-06-17T19:13:42.073 回答