Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Impossible to use django-cockroachdb with psycopg2-binary

See original GitHub issue

Issue Description

pipenv install django-cockroachdb==3.0
Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Creating a virtualenv for this project…
Pipfile: /Users/me/Desktop/djtest/Pipfile
Using /usr/local/Cellar/pipenv/2018.11.26_3/libexec/bin/python3.8 (3.8.1) to create virtualenv…
⠹ Creating virtual environment...Already using interpreter /usr/local/Cellar/pipenv/2018.11.26_3/libexec/bin/python3.8
Using real prefix '/usr/local/Cellar/python@3.8/3.8.1/Frameworks/Python.framework/Versions/3.8'
New python executable in /Users/me/.local/share/virtualenvs/djtest-QZ45VGf8/bin/python3.8
Also creating executable in /Users/me/.local/share/virtualenvs/djtest-QZ45VGf8/bin/python
Installing setuptools, pip, wheel...

✔ Successfully created virtual environment! 
Virtualenv location: /Users/me/.local/share/virtualenvs/djtest-QZ45VGf8
Creating a Pipfile for this project…
Installing django-cockroachdb==3.0…
Adding django-cockroachdb to Pipfile's [packages]…
✔ Installation Succeeded 
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✔ Success! 
Updated Pipfile.lock (676edb)!
Installing dependencies from Pipfile.lock (676edb)…
An error occurred while installing psycopg2==2.8.4 --hash=sha256:4212ca404c4445dc5746c0d68db27d2cbfb87b523fe233dc84ecd24062e35677 --hash=sha256:47fc642bf6f427805daf52d6e52619fe0637648fe27017062d898f3bf891419d --hash=sha256:72772181d9bad1fa349792a1e7384dde56742c14af2b9986013eb94a240f005b --hash=sha256:8396be6e5ff844282d4d49b81631772f80dabae5658d432202faf101f5283b7c --hash=sha256:893c11064b347b24ecdd277a094413e1954f8a4e8cdaf7ffbe7ca3db87c103f0 --hash=sha256:92a07dfd4d7c325dd177548c4134052d4842222833576c8391aab6f74038fc3f --hash=sha256:965c4c93e33e6984d8031f74e51227bd755376a9df6993774fd5b6fb3288b1f4 --hash=sha256:9ab75e0b2820880ae24b7136c4d230383e07db014456a476d096591172569c38 --hash=sha256:b0845e3bdd4aa18dc2f9b6fb78fbd3d9d371ad167fd6d1b7ad01c0a6cdad4fc6 --hash=sha256:dca2d7203f0dfce8ea4b3efd668f8ea65cd2b35112638e488a4c12594015f67b --hash=sha256:ed686e5926929887e2c7ae0a700e32c6129abb798b4ad2b846e933de21508151 --hash=sha256:ef6df7e14698e79c59c7ee7cf94cd62e5b869db369ed4b1b8f7b729ea825712a --hash=sha256:f898e5cc0a662a9e12bde6f931263a1bbd350cfb18e1d5336a12927851825bb6! Will try again.
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 2/2 — 00:00:01
Installing initially failed dependencies…
[pipenv.exceptions.InstallError]:   File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/", line 1983, in do_install
[pipenv.exceptions.InstallError]:       do_init(
[pipenv.exceptions.InstallError]:   File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/", line 1246, in do_init
[pipenv.exceptions.InstallError]:       do_install_dependencies(
[pipenv.exceptions.InstallError]:   File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/", line 858, in do_install_dependencies
[pipenv.exceptions.InstallError]:       batch_install(
[pipenv.exceptions.InstallError]:   File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/", line 763, in batch_install
[pipenv.exceptions.InstallError]:       _cleanup_procs(procs, not blocking, failed_deps_queue, retry=retry)
[pipenv.exceptions.InstallError]:   File "/usr/local/Cellar/pipenv/2018.11.26_3/libexec/lib/python3.8/site-packages/pipenv/", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]:       raise exceptions.InstallError(, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Collecting psycopg2==2.8.4', '  Using cached psycopg2-2.8.4.tar.gz (377 kB)']
[pipenv.exceptions.InstallError]: ['ERROR: Command errored out with exit status 1:', '     command: /Users/me/.local/share/virtualenvs/djtest-QZ45VGf8/bin/python3.8 -c \'import sys, setuptools, tokenize; sys.argv[0] = \'"\'"\'/private/var/folders/_d/pcm157vn4kg3mv8wvb37vy2w0000gn/T/pip-install-v1m062jh/psycopg2/\'"\'"\'; __file__=\'"\'"\'/private/var/folders/_d/pcm157vn4kg3mv8wvb37vy2w0000gn/T/pip-install-v1m062jh/psycopg2/\'"\'"\';f=getattr(tokenize, \'"\'"\'open\'"\'"\', open)(__file__);\'"\'"\'\\r\\n\'"\'"\', \'"\'"\'\\n\'"\'"\');f.close();exec(compile(code, __file__, \'"\'"\'exec\'"\'"\'))\' egg_info --egg-base /private/var/folders/_d/pcm157vn4kg3mv8wvb37vy2w0000gn/T/pip-install-v1m062jh/psycopg2/pip-egg-info', '         cwd: /private/var/folders/_d/pcm157vn4kg3mv8wvb37vy2w0000gn/T/pip-install-v1m062jh/psycopg2/', '    Complete output (23 lines):', '    running egg_info', '    creating /private/var/folders/_d/pcm157vn4kg3mv8wvb37vy2w0000gn/T/pip-install-v1m062jh/psycopg2/pip-egg-info/psycopg2.egg-info', '    writing /private/var/folders/_d/pcm157vn4kg3mv8wvb37vy2w0000gn/T/pip-install-v1m062jh/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO', '    writing dependency_links to /private/var/folders/_d/pcm157vn4kg3mv8wvb37vy2w0000gn/T/pip-install-v1m062jh/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt', '    writing top-level names to /private/var/folders/_d/pcm157vn4kg3mv8wvb37vy2w0000gn/T/pip-install-v1m062jh/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt', "    writing manifest file '/private/var/folders/_d/pcm157vn4kg3mv8wvb37vy2w0000gn/T/pip-install-v1m062jh/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt'", '    ', '    Error: pg_config executable not found.', '    ', '    pg_config is required to build psycopg2 from source.  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'.", '    ', '    If you prefer to avoid building psycopg2 from source, please install the PyPI', "    'psycopg2-binary' package instead.", '    ', "    For further information please check the 'doc/src/install.rst' file (also at", '    <>).', '    ', '    ----------------------------------------', 'ERROR: Command errored out with exit status 1: python egg_info Check the logs for full command output.']
ERROR: ERROR: Package installation failed...
  ☤  ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 0/1 — 00:00:01

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

timgrahamcommented, Mar 27, 2020

Ok, I can reproduce on a different machine from the one I tried earlier. I guess my main machine has a cached psycopg2 wheel that was working.

So the options here appear to be:

  • Keep psycopg2 as the dependency and require users install PostgreSQL.
  • Change the dependency to psycopg2-binary. That would be against psycopg2’s own recommendation:

The psycopg2-binary package is meant for beginners to start playing with Python and PostgreSQL without the need to meet the build requirements. If you are the maintainer of a publish package depending on psycopg2 you shouldn’t use ‘psycopg2-binary’ as a module dependency. For production use you are advised to use the source

  • Remove the psycopg2 dependency and require django-cockroachdb users to manually install either psycopg2 or psycopg2-binary.
timgrahamcommented, Apr 16, 2020

I amended #130 to point to which mentions libpq-dev.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build a Python App with CockroachDB and psycopg2
This tutorial shows you how build a simple Python application with CockroachDB and the psycopg2 driver. Step 1. Start CockroachDB. Use CockroachDB serverless...
Read more >
django-cockroachdb/ at master - GitHub
The binary package is a practical choice for development and testing but in production it is advised to use the package built from...
Read more >
Can't install psycopg2-binary - Stack Overflow
pip3 install psycopg2, pip install psycopg2 - the same problem. PS The problem was solved via updating pip (pip install --upgrade pip). django...
Read more >
Passing parameters to SQL queries - Psycopg
Usually the binary format is more efficient to use. Psycopg can support both formats for each data type. Whenever a value is passed...
Read more >
encountered error while trying to install package psycopg2 ...
I want to learn to develop websites with Python and Django. ... But while trying to install psycopg2-binary on my Mac to work...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found