I am using Mac OS Catalina Version 10.15.2 and Xcode Version 11.3. After some issues I managed to install psycopg2 with the help of this post: Python 3.7 psycopg2 - Xcode Error "error: command 'gcc' failed with exit status 1"
Psycopg2 was required since I am developing an application using Python 3.7, Kivy and a PostgreSQL (12) database, which I want to run on my iPhone. Using PyCharm, the preview/ GUI runs without any problems. Also the database access, queries and the import of psycopg2 works without any problems. For my project I have 2 .py files (main.py and queries.py).
I installed psycopg2 using pip3 install psycopg2==2.7.7
and pip3 install psycopg2-binary
, since I am also working with Python 3.7 for the project. I installed version 2.7.7 since version 2.8.4 of psycopg2 did cause several other issues, which did not even let me run the project in PyCharm.
When I now try to build the application using Xcode it does show me "Build succeeded" but then crashes with the error code 'ModuleNotFoundError: No module named 'psycopg2'.
If I try to install psycopg2 again it does tell me that it is already installed
Jans-MBP:~ jang$ pip3 install psycopg2==2.7.7
Requirement already satisfied: psycopg2==2.7.7 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2.7.7)