Simple solution: this pip command will install a package at a specific location:
pip install psycopg2-binary -t PATH
Where PATH is a path that you specify.
To test this, install the package in a folder on your desktop.
Then put a python script in the same folder that will import psycopg2. It should work with the script being in the same location as the psycopg2 package.
Comments:
This reason we need psycopg2-binary, according to old documentation that I found online:
"The binary packages come with their own versions of a few C libraries, among which libpq and libssl , which will be used regardless of other libraries available on the client: upgrading the system libraries will not upgrade the libraries used by psycopg2 . Please build psycopg2 from source if you want to maintain binary upgradeability."
Source:
https://access.crunchydata.com/documentation/psycopg2/2.7.3/install.html#install-from-source
I realized the issue has been that python's site package directory needs to be referenced. The location for this on my computer is:
/Users/my_name/Library/Python/3.7/lib/python/site-packages
Now, if you want to use IDLE or say PyCharm as I have been, the installation of psycopg2-binary needs to target this site directory. Additionally, you'll find two folders that appear after installing psycopg2-binary called: psycopg2, psycopg2_binary-2.8.4.dist-info
I spent a long time investigating this issue. The other methods out there were not not resolving the issue as seen above regarding lib ssl and reason image not found.
Setup: macOS Catalina, Python 3.7, PyCharm/IDLE project on Desktop, [email protected]/1.1.1d
~/.bash_profile
:export DYLD_FALLBACK_LIBRARY_PATH=$HOME/anaconda/lib:$DYLD_FALLBACK_LIBRARY_PATH
. Or if you're using the fish shell, add the following to yourconfig.fish
(normally located at~/.config/fish/config.fish
):set -x DYLD_FALLBACK_LIBRARY_PATH $HOME/anaconda/lib $DYLD_FALLBACK_LIBRARY_PATH
. – Philips$DYLD_FALLBACK_PATH
). Check out my solution below: https://mcmap.net/q/321446/-import-psycopg2-library-not-loaded-libssl-1-0-0-dylib – Apo