Ask Your Question

Cannot install psycopg2

asked 2017-02-28 14:12:36 +0200

stan gravatar image

Using sage 7.3, I tried:

sage -sh
pip install psycopg2

and got

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 build_ext --pg-config /path/to/pg_config build ...

or with the pg_config option in 'setup.cfg'.

Others stated that one needs to install libpq-dev and python-dev to solve the problem (, but how do I do this in sage? pip install libpq-dev does not work.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-02-28 22:52:41 +0200

tmonteil gravatar image

If you are using Debian or Ubuntu, you can try the following (from a terminal):

sudo apt install libpq-dev python-dev
sage -pip install psycopg2

If not, could you please give us some informations so that someone can try to reproduce your problem:

  • which OS ?
  • did you install Sage from the binaries, and which ones ?
  • did you compile Sage yourself ?
  • ... ?
edit flag offensive delete link more


Thanks, but I already tried to install libpq-dev, system wide on Debian jessy but without success:

The following packages have unmet dependencies:
 libpq-dev : Depends: krb5-multidev but it is not going to be installed
             Depends: comerr-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

It wasn't clear to me whether installing it using apt would make it available within sage, so I didn't follow up on the error message. Is there a description somewhere how python in sage interacts with the system-wide python? This is on sage 7.3, not sure if I installed from the the binaries for Debian or if I compiled it myself. Perhaps I should update to 7.4 and try again?

stan gravatar imagestan ( 2017-03-01 20:19:53 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-02-28 14:12:36 +0200

Seen: 490 times

Last updated: Feb 28 '17