0

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)
Cœur
  • 37,241
  • 25
  • 195
  • 267
confusionm
  • 49
  • 2
  • 6

1 Answers1

0

The library had to be manually installed using the toolchain.py of the kivy-ios packaging.

  1. Set the directory to your kivy-ios package, which does contain the toolchain.py

    $ cd /Users/jg/MainApp/kivy-ios

  2. Install the required package using toolchain.py

    $ python3 toolchain.py pip3 install psycopg2

Now the Build should succeed and Xcode should find the required module. If you experience some issues with the location of the iPhone simulator while trying to install the library, then try to change the path of your Xcode:

$ sudo xcode-select --switch /Applications/Xcode.app

Changing the Xcode path did finally solve the problem, thanks to this post: https://github.com/kivy/kivy-ios/issues/373

confusionm
  • 49
  • 2
  • 6