pypa / pipenv

Python Development Workflow for Humans.
https://pipenv.pypa.io
MIT License
24.83k stars 1.87k forks source link

Pipenv fails to install psycopg2 #3991

Closed ye closed 4 years ago

ye commented 4 years ago

Issue description

pipenv install psycopg2 failed, even though the Pipfile and Pipfile.lock files included the entries and hashes for packages.

Also I noticed that pip install psycopg2 also failed: https://gist.github.com/ye/bf1198cc15d9a6a177bae8bc0fc0aff9#file-pip-install-psycopg2-log

Also after the pip install failure, the pip inside pipenv virtual environment is borked.

$ pip -V                                                                                                                                                                                                                                                                                                                                                                                  
dyld: Library not loaded: @executable_path/../.Python
  Referenced from: /Users/ye/.venvs/server-D2-ixepO/bin/python3.7
  Reason: image not found
[1]    5466 abort      pip -V

Expected result

I expect it should install successfully.

Actual result

https://gist.github.com/ye/bf1198cc15d9a6a177bae8bc0fc0aff9

Steps to replicate

pipenv install psycopg2


$ pipenv --support Pipenv version: `'2018.11.26'` Pipenv location: `'/usr/local/lib/python3.7/site-packages/pipenv'` Python location: `'/usr/local/opt/python/bin/python3.7'` Python installations found: - `3.7.4`: `/Users/ye/.venvs/server-D2-ixepO/bin/python3` - `3.7.4`: `/usr/local/bin/python3` - `3.7.4`: `/usr/local/bin/python3.7m` - `2.7.10`: `/usr/bin/python` - `2.7.10`: `/usr/bin/pythonw` - `2.7.10`: `/usr/bin/python2.7` PEP 508 Information: ``` {'implementation_name': 'cpython', 'implementation_version': '3.7.4', 'os_name': 'posix', 'platform_machine': 'x86_64', 'platform_python_implementation': 'CPython', 'platform_release': '18.7.0', 'platform_system': 'Darwin', 'platform_version': 'Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT ' '2019; root:xnu-4903.271.2~2/RELEASE_X86_64', 'python_full_version': '3.7.4', 'python_version': '3.7', 'sys_platform': 'darwin'} ``` System environment variables: - `TERM_SESSION_ID` - `SSH_AUTH_SOCK` - `LC_TERMINAL_VERSION` - `Apple_PubSub_Socket_Render` - `COLORFGBG` - `ITERM_PROFILE` - `SQLITE_EXEMPT_PATH_FROM_VNODE_GUARDS` - `XPC_FLAGS` - `LANG` - `PWD` - `SHELL` - `SECURITYSESSIONID` - `TERM_PROGRAM_VERSION` - `TERM_PROGRAM` - `PATH` - `LC_TERMINAL` - `COLORTERM` - `COMMAND_MODE` - `TERM` - `HOME` - `TMPDIR` - `USER` - `XPC_SERVICE_NAME` - `LOGNAME` - `__CF_USER_TEXT_ENCODING` - `ITERM_SESSION_ID` - `SHLVL` - `OLDPWD` - `ZSH` - `GOPATH` - `PAGER` - `LESS` - `LSCOLORS` - `VIRTUAL_ENV_DISABLE_PROMPT` - `WORKON_HOME` - `PROJECT_HOME` - `VIRTUALENVWRAPPER_PYTHON` - `VIRTUALENVWRAPPER_VIRTUALENV` - `VIRTUALENVWRAPPER_PROJECT_FILENAME` - `VIRTUALENVWRAPPER_WORKON_CD` - `VIRTUALENVWRAPPER_SCRIPT` - `VIRTUALENVWRAPPER_HOOK_DIR` - `PIP_DISABLE_PIP_VERSION_CHECK` - `PYTHONDONTWRITEBYTECODE` - `PIP_PYTHON_PATH` - `PIPENV_ACTIVE` - `VIRTUAL_ENV` - `_` - `PIP_SHIMS_BASE_MODULE` - `PYTHONFINDER_IGNORE_UNSUPPORTED` Pipenv–specific environment variables: - `PIPENV_ACTIVE`: `1` Debug–specific environment variables: - `PATH`: `/Users/ye/.venvs/server-D2-ixepO/bin:/Users/ye/.cargo/bin:/usr/local/sbin:/Users/ye/Library/Python/3.7/bin:/Users/ye/bin:/Users/ye/.cargo/bin:/usr/local/sbin:/usr/local/opt/gettext/bin:/Users/ye/Library/Python/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Users/ye/.cargo/bin:/Users/ye/.poetry/bin` - `SHELL`: `/bin/zsh` - `LANG`: `en_US.UTF-8` - `PWD`: `/Users/ye/website/server` - `VIRTUAL_ENV`: `/Users/ye/.venvs/server-D2-ixepO` --------------------------- Contents of `Pipfile` ('/Users/ye/website/server/Pipfile'): ```toml [[source]] name = "pypi" url = "https://pypi.org/simple" verify_ssl = true [dev-packages] [packages] ipython = "*" flask = "*" sqlalchemy = "*" flask-sqlalchemy = "*" flask-admin = "*" flask-login = "*" [requires] python_version = "3.7" ``` Contents of `Pipfile.lock` ('/Users/ye/website/server/Pipfile.lock'): ```json { "_meta": { "hash": { "sha256": "39be307e901dd24694fdcd3df287b62eb1265d908ac3d91d854703c3e8acd897" }, "pipfile-spec": 6, "requires": { "python_version": "3.7" }, "sources": [ { "name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true } ] }, "default": { "appnope": { "hashes": [ "sha256:5b26757dc6f79a3b7dc9fab95359328d5747fcb2409d331ea66d0272b90ab2a0", "sha256:8b995ffe925347a2138d7ac0fe77155e4311a0ea6d6da4f5128fe4b3cbe5ed71" ], "markers": "sys_platform == 'darwin'", "version": "==0.1.0" }, "backcall": { "hashes": [ "sha256:38ecd85be2c1e78f77fd91700c76e14667dc21e2713b63876c0eb901196e01e4", "sha256:bbbf4b1e5cd2bdb08f915895b51081c041bac22394fdfcfdfbe9f14b77c08bf2" ], "version": "==0.1.0" }, "click": { "hashes": [ "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13", "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7" ], "version": "==7.0" }, "decorator": { "hashes": [ "sha256:86156361c50488b84a3f148056ea716ca587df2f0de1d34750d35c21312725de", "sha256:f069f3a01830ca754ba5258fde2278454a0b5b79e0d7f5c13b3b97e57d4acff6" ], "version": "==4.4.0" }, "flask": { "hashes": [ "sha256:13f9f196f330c7c2c5d7a5cf91af894110ca0215ac051b5844701f2bfd934d52", "sha256:45eb5a6fd193d6cf7e0cf5d8a5b31f83d5faae0293695626f539a823e93b13f6" ], "index": "pypi", "version": "==1.1.1" }, "flask-admin": { "hashes": [ "sha256:ca0be6ec11a6913b73f656c65c444ae5be416c57c75638dd3199376ce6bc7422" ], "index": "pypi", "version": "==1.5.3" }, "flask-login": { "hashes": [ "sha256:c815c1ac7b3e35e2081685e389a665f2c74d7e077cb93cecabaea352da4752ec" ], "index": "pypi", "version": "==0.4.1" }, "flask-sqlalchemy": { "hashes": [ "sha256:0078d8663330dc05a74bc72b3b6ddc441b9a744e2f56fe60af1a5bfc81334327", "sha256:6974785d913666587949f7c2946f7001e4fa2cb2d19f4e69ead02e4b8f50b33d" ], "index": "pypi", "version": "==2.4.1" }, "ipython": { "hashes": [ "sha256:c4ab005921641e40a68e405e286e7a1fcc464497e14d81b6914b4fd95e5dee9b", "sha256:dd76831f065f17bddd7eaa5c781f5ea32de5ef217592cf019e34043b56895aa1" ], "index": "pypi", "version": "==7.8.0" }, "ipython-genutils": { "hashes": [ "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8", "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8" ], "version": "==0.2.0" }, "itsdangerous": { "hashes": [ "sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19", "sha256:b12271b2047cb23eeb98c8b5622e2e5c5e9abd9784a153e9d8ef9cb4dd09d749" ], "version": "==1.1.0" }, "jedi": { "hashes": [ "sha256:786b6c3d80e2f06fd77162a07fed81b8baa22dde5d62896a790a331d6ac21a27", "sha256:ba859c74fa3c966a22f2aeebe1b74ee27e2a462f56d3f5f7ca4a59af61bfe42e" ], "version": "==0.15.1" }, "jinja2": { "hashes": [ "sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f", "sha256:9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de" ], "version": "==2.10.3" }, "markupsafe": { "hashes": [ "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7" ], "version": "==1.1.1" }, "parso": { "hashes": [ "sha256:63854233e1fadb5da97f2744b6b24346d2750b85965e7e399bec1620232797dc", "sha256:666b0ee4a7a1220f65d367617f2cd3ffddff3e205f3f16a0284df30e774c2a9c" ], "version": "==0.5.1" }, "pexpect": { "hashes": [ "sha256:2094eefdfcf37a1fdbfb9aa090862c1a4878e5c7e0e7e7088bdb511c558e5cd1", "sha256:9e2c1fd0e6ee3a49b28f95d4b33bc389c89b20af6a1255906e90ff1262ce62eb" ], "markers": "sys_platform != 'win32'", "version": "==4.7.0" }, "pickleshare": { "hashes": [ "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca", "sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56" ], "version": "==0.7.5" }, "prompt-toolkit": { "hashes": [ "sha256:46642344ce457641f28fc9d1c9ca939b63dadf8df128b86f1b9860e59c73a5e4", "sha256:e7f8af9e3d70f514373bf41aa51bc33af12a6db3f71461ea47fea985defb2c31", "sha256:f15af68f66e664eaa559d4ac8a928111eebd5feda0c11738b5998045224829db" ], "version": "==2.0.10" }, "ptyprocess": { "hashes": [ "sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0", "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f" ], "version": "==0.6.0" }, "pygments": { "hashes": [ "sha256:71e430bc85c88a430f000ac1d9b331d2407f681d6f6aec95e8bcfbc3df5b0127", "sha256:881c4c157e45f30af185c1ffe8d549d48ac9127433f2c380c24b84572ad66297" ], "version": "==2.4.2" }, "six": { "hashes": [ "sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "sha256:d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73" ], "version": "==1.12.0" }, "sqlalchemy": { "hashes": [ "sha256:0f0768b5db594517e1f5e1572c73d14cf295140756431270d89496dc13d5e46c" ], "index": "pypi", "version": "==1.3.10" }, "traitlets": { "hashes": [ "sha256:70b4c6a1d9019d7b4f6846832288f86998aa3b9207c6821f3578a6a6a467fe44", "sha256:d023ee369ddd2763310e4c3eae1ff649689440d4ae59d7485eb4cfbbe3e359f7" ], "version": "==4.3.3" }, "wcwidth": { "hashes": [ "sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e", "sha256:f4ebe71925af7b40a864553f761ed559b43544f8f71746c2d756c7fe788ade7c" ], "version": "==0.1.7" }, "werkzeug": { "hashes": [ "sha256:7280924747b5733b246fe23972186c6b348f9ae29724135a6dfc1e53cea433e7", "sha256:e5f4a1f98b52b18a93da705a7458e55afb26f32bff83ff5d19189f92462d65c4" ], "version": "==0.16.0" }, "wtforms": { "hashes": [ "sha256:0cdbac3e7f6878086c334aa25dc5a33869a3954e9d1e015130d65a69309b3b61", "sha256:e3ee092c827582c50877cdbd49e9ce6d2c5c1f6561f849b3b068c1b8029626f1" ], "version": "==2.2.1" } }, "develop": {} } ```
frostming commented 4 years ago

Not an issue related to pipenv

workaround:

  1. Purge the virtualenv by pipenv --rm
  2. Install binary version: pipenv install psycopg2-binary
robertsutherland commented 4 years ago

I am having a similar issue on macOS Mojave 10.14.4.

pipenv install psycopg2 fails However, pipenv run pip install psycopg2 successfully installs psycopg2

ghost commented 4 years ago

^ Expanding on @robertsutherland I had to run pipenv run pip install psycopg2-binary

menghuu commented 4 years ago

@HashRocketSyntax It seems very bad, because when we use the pipenv, we want to record the deps, if pipenv run pip install psycopg2-binary, there is nothing to record in Pipfile/Pipfile.lock.

trying pipenv install psycopg2-binary insead.

if it not works, you(everyone) should consider the bugs of pipenv(and the long-time no-releasing risk) and the benefits of pipenv, then, decide to change to other tool(pip-tools/poetry/or even raw requirements.txt) or keep using this tool

ghost commented 4 years ago

@menghuu that did not work despite checking all homebrew set config and path + adding more libs, which is why I resorted to piping in run pip.

ye commented 4 years ago

Not an issue related to pipenv

workaround:

  1. Purge the virtualenv by pipenv --rm
  2. Install binary version: pipenv install psycopg2-binary

@frostming can you elaborate why this is not an issue related to pipenv? And why purging virtualenv would make it work?

By the way, pipenv install psycopg2-binary didn't work for me.

$ pipenv --rm
Removing virtualenv (/Users/ye/.venvs/server-D2-ixepO)…
$ pipenv install psycopg2-binary
Creating a virtualenv for this project…
Pipfile: /Users/ye/dev/website-react/server/Pipfile
Using /usr/local/bin/python3 (3.7.4) to create virtualenv…
⠧ Creating virtual environment...Already using interpreter /usr/local/opt/python/bin/python3.7
Using base prefix '/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7'
New python executable in /Users/ye/.venvs/server-D2-ixepO/bin/python3.7
Also creating executable in /Users/ye/.venvs/server-D2-ixepO/bin/python
Installing setuptools, pip, wheel...
done.
Running virtualenv with interpreter /usr/local/bin/python3

✔ Successfully created virtual environment!
Virtualenv location: /Users/ye/.venvs/server-D2-ixepO
Installing psycopg2-binary…
Adding psycopg2-binary to Pipfile's [packages]…
✔ Installation Succeeded
Pipfile.lock (49ca5b) out of date, updating to (2a2c3b)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✘ Locking Failed!
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/resolver.py", line 69, in resolve
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches google-cloud-python
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches google-cloud-python
No versions found
Was https://pypi.org/simple reachable?
[pipenv.exceptions.ResolutionFailure]:       req_dir=requirements_dir
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 726, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       req_dir=req_dir,
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/usr/local/lib/python3.7/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches google-cloud-python
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches google-cloud-python
No versions found
Was https://pypi.org/simple reachable?
StarryShark commented 4 years ago

I heard good things about Pipenv so I thought of giving a go but ran into the issue installing psycopg2 described by others above. I guess I am back to venv and pip but will try again Pipenv in a few months.

frostming commented 4 years ago

@ye Sorry for the late reply

Purging virtualenv is to fix any potential breakage of the venv.

By the way, pipenv install psycopg2-binary didn't work for me.

But your output is about another package google-cloud-python, there is no such package on PyPI, but google-cloud is available.

roansong commented 4 years ago

I've been using pipenv install psycopg2 --sequential (also using --sequential with update and sync). It works for me, but it isn't quite ideal.

shaurmanchic commented 4 years ago

Not an issue related to pipenv

workaround:

  1. Purge the virtualenv by pipenv --rm
  2. Install binary version: pipenv install psycopg2-binary

From psycopg installation page:

Note 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 distribution.

Psycopg devs have already made their point that they won't be fixing this: https://github.com/psycopg/psycopg2/issues/883

Did anyone find a way to fix this without running additional build steps?

vignzpie commented 4 years ago

Exporting some flags as per this thread worked for me!

export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include"

shaurmanchic commented 4 years ago

Exporting some flags as per this thread worked for me!

`export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include"

Thanks @vignzpie ! You solved it for me :)

pawelrubin commented 4 years ago

installing dependencies solved it for me

$ sudo apt-get install libpq-dev
ye commented 4 years ago

installing dependencies solved it for me

$ sudo apt-get install libpq-dev

@pawelrubin my issue was filed for macOS not on linux as you can see in the log: 'platform_system': 'Darwin'.

frostming commented 4 years ago

@ye then you should take either of the following solutions:

  1. Use psycopg2-binary package instead
  2. Install postgres via homebrew and expose the source header files by modifying LDFLAGS and CPPFLAGS env vars.
ye commented 4 years ago

@frostming yes it was due to a openssl lib linking issue while compiling psycopg2 from source. Thanks.

Both 1 and 2 work now after I upgrade to python 3.8 and installing psychopg2 version 2.8.5 but 1 is not a recommended solution as @shaurmanchic pointed out (https://github.com/pypa/pipenv/issues/3991#issuecomment-564498875)

Exporting some flags as per this thread worked for me!

export LDFLAGS="-L/usr/local/opt/openssl/lib" export CPPFLAGS="-I/usr/local/opt/openssl/include"

@vignzpie 's solution worked for me on psycopg2 version 2.8.5

nextwebb commented 4 years ago

If you're here on Linux mint 19 Cinnamon 4.6.7 installing dependencies solved it for me:

HanMin189 commented 3 years ago

installing dependencies solved it for me

$ sudo apt-get install libpq-dev

this also help

mchogan commented 3 years ago

pipenv install psycopg2-binary is Working on Windows 10 with Python 3.8 as of today.

  1. Install Python 3.8 from the Microsoft Store
  2. Install postgresql-12.5-1-windows-x64 (version 13 is not yet supported!)
  3. Use Application Stack Builder to install PostGIS 3.1
  4. Install osgeo4w-setup-x86_64 (say no to all prompts to set variables)
  5. Modify the Windows Environment (see code block below)
  6. pipenv install psycopg2-binary
set OSGEO4W_ROOT=C:\OSGeo4W64
set GDAL_DATA=%OSGEO4W_ROOT%\share\gdal
set PROJ_LIB=%OSGEO4W_ROOT%\share\proj
set PATH=%PATH%;%OSGEO4W_ROOT%\bin
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path /t REG_EXPAND_SZ /f /d "%PATH%"
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v GDAL_DATA /t REG_EXPAND_SZ /f /d "%GDAL_DATA%"
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROJ_LIB /t REG_EXPAND_SZ /f /d "%PROJ_LIB%"

These steps were documented in the GeoDjango Windows installation instructions.

CHANG-CHING-CHUNG commented 3 years ago
$ sudo apt-get install libpq-dev

You saved me ! Thank you!

andrewoverton commented 3 years ago

pipenv install psycopg2-binary==2.8.5 wasn't working for me. The comments involving LDFLAGS and CPPFLAGS didn't resolve my issue, but this appears to have:

1) I followed instructions to install PostgreSQL at https://www.postgresql.org/download/macosx/ (I have a mac) 2) I added this line to my ~/.zshrc: export PATH="/Library/PostgreSQL/13/bin:$PATH" (Replace the 13 with whatever version you download)

justsasri commented 3 years ago
$ sudo apt-get install libpq-dev
$ pipenv --rm
$ pipenv install
$ pipenv install psycopg2

Ubuntu 20.04 WSL2 in Windows 10 ..

HT-Moh commented 2 years ago

Using ubuntu 20.04. with multiple python versions 3.8, 3.7..etc and working in a django project using python 3.7 with pipenv, the following worked for me:

Solution:

sudo apt-get update
sudo apt-get install libpq-dev python3.7-dev
pipenv install --python=3.7 psycopg2
pipenv shell
Bohooslav commented 2 years ago

I have the same issue with fedora 35. I have installed postgresql-devel, tried all the suggestions listed above and nothing works.

VishvashDwivedi commented 2 years ago

Who so ever is struggling and is unable to install psycopg2 and can refer to this comment,

To install psycopg2 in Mac :

  1. run command : export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/14/bin Make sure you have your version of Postgres.app written in the command in place of 14(which is mine version.)

  2. pipenv install wheel

  3. pipenv install setuptools

  4. pipenv install psycopg2.

and, It worked for me.

Bohooslav commented 2 years ago

I updated python version, and it worked fine for me.

VishvashDwivedi commented 2 years ago

Which version of python are you using ? and did you installed it on mac or windows ?

Bohooslav commented 2 years ago

Which version of python are you using ? and did you installed it on mac or windows ?

I am using Fedora Linux. When I reinstalled the pipenv environment with python 3.10 it worked well.

VishvashDwivedi commented 2 years ago

The problem is there for mac, I tried installing it on mac with the latest version of python, still it was not working.When I followed the above steps only then it worked.