1

I am running OSX 10.12.2 (16C67) and 3.6.0 inside virtualenv.

I have tested following.

➜  ~ 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

Checked that XCode tools are installed. But I keep getting errors when trying to install psycopg2. Any ideas what to do next.

** EDIT

I just tried to install it outside the virtualenv using same Python version and it installed without any issues.

➜  ~ 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

2 Answers 2

1

Both Python 2 and Python 3 have a pip utility associated with them. Therefore, if you install both in the same directory the second installation runs the risk of overwriting the pip from the first one.

It's always safest to run python2 -m pip or python3 -m pip if you want to be sure which version you are running.

Once you've correctly activated a virtual environment, its pip should be the one that runs by default, ensuring that installation happens inside the virtual environment. If the virtualenv doesn't include pip you will find it more difficult ti install packages into your virtualenv.

Sign up to request clarification or add additional context in comments.

Comments

0

It seems that with my configuration pip install -r requirements.txt fails when using python3.

I solved this by running pip uninstall -r requirements.txt and then running pip3 install -r requirements.txt

5 Comments

It seems there's some confusion about which pip will execute. This isn't good. Under these circumstances (assuming you know which python will run :-)) it's often better to use python -m pip instead
Ah never realised I could run pip like any other Python module with -m flag. Yes that might be better idea
Yes, it processes arguments just like pip and makes it easier to determine which one to use. But I suspect the real issue is having python2 and python3 installed in the same directory
If you want write an aswer with it and I accept. Else thanks with the help anyway.
Cool. It's probably also good to retain this answer, since others will undoubtedly be grateful for your suggestion of how to get rid of the wrong stuff.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.