我在virtualenv中运行OSX 10.12.2(16C67)和3.6.0。
我测试了以下内容。
➜ ~ brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
➜ ~ pg_config
BINDIR = /usr/local/Cellar/postgresql/9.6.1/bin
DOCDIR = /usr/local/Cellar/postgresql/9.6.1/share/doc/postgresql
HTMLDIR = /usr/local/Cellar/postgresql/9.6.1/share/doc/postgresql
INCLUDEDIR = /usr/local/Cellar/postgresql/9.6.1/include
PKGINCLUDEDIR = /usr/local/Cellar/postgresql/9.6.1/include
INCLUDEDIR-SERVER = /usr/local/Cellar/postgresql/9.6.1/include/server
LIBDIR = /usr/local/lib
PKGLIBDIR = /usr/local/lib/postgresql
LOCALEDIR = /usr/local/Cellar/postgresql/9.6.1/share/locale
MANDIR = /usr/local/Cellar/postgresql/9.6.1/share/man
SHAREDIR = /usr/local/share/postgresql
SYSCONFDIR = /usr/local/etc/postgresql
PGXS = /usr/local/lib/postgresql/pgxs/src/makefiles/pgxs.mk
CONFIGURE = '--disable-debug' '--prefix=/usr/local/Cellar/postgresql/9.6.1' '--datadir=/usr/local/share/postgresql' '--libdir=/usr/local/lib' '--sysconfdir=/usr/local/etc' '--docdir=/usr/local/Cellar/postgresql/9.6.1/share/doc/postgresql' '--enable-thread-safety' '--with-bonjour' '--with-gssapi' '--with-ldap' '--with-openssl' '--with-pam' '--with-libxml' '--with-libxslt' '--with-perl' '--with-tcl' '--with-tclconfig=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/lib' '--with-uuid=e2fs' 'CC=clang' 'LDFLAGS=-L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib' 'CPPFLAGS=-I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include'
CC = clang
CPPFLAGS = -DFRONTEND -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2
CFLAGS = -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -Wno-unused-command-line-argument -O2
CFLAGS_SL =
LDFLAGS = -L../../src/common -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -Wl,-dead_strip_dylibs
LDFLAGS_EX =
LDFLAGS_SL =
LIBS = -lpgcommon -lpgport -lxslt -lxml2 -lpam -lssl -lcrypto -lgssapi_krb5 -lz -lreadline -lm
VERSION = PostgreSQL 9.6.1
➜ ~ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
检查是否已安装XCode工具。但是在尝试安装psycopg2时我一直遇到错误。任何想法下一步该做什么。
**编辑
我只是尝试使用相同的Python版本在virtualenv之外安装它,并且安装时没有任何问题。
➜ ~ pip3 install psycopg2
Collecting psycopg2
Using cached psycopg2-2.6.2.tar.gz
Building wheels for collected packages: psycopg2
Running setup.py bdist_wheel for psycopg2 ... done
Stored in directory: /Users/Kimmo/Library/Caches/pip/wheels/49/47/2a/5c3f874990ce267228c2dfe7a0589f3b0651aa590e329ad382
Successfully built psycopg2
Installing collected packages: psycopg2
Successfully installed psycopg2-2.
6.2
答案 0 :(得分:1)
Python 2和Python 3都有一个pip
实用程序与它们相关联。因此,如果您在同一目录中同时安装,则第二次安装可能会覆盖第一次安装中的pip
。
如果您想确定自己正在运行哪个版本,运行python2 -m pip
或python3 -m pip
始终最安全。
一旦您正确激活了虚拟环境,其 pip
应该是默认运行的,确保安装在虚拟环境中进行。如果virtualenv没有包含pip,你会发现在你的virtualenv中安装包更加困难。
答案 1 :(得分:0)
使用python3时,似乎我的配置pip install -r requirements.txt
失败了。
我通过运行pip uninstall -r requirements.txt
然后运行pip3 install -r requirements.txt