I am trying to utilize the kivy toolchain to run a Python module that uses numpy in a preexisting iOS application. I started by using the toolchain create tool to familiarize myself with the kivy environment. This worked great, I got Python up and running and was able to use numpy for basic calculations. I then isolated the toolchain into its own directory, did some set up and got another tutorial project running fine with the kivy create command.
Then, to learn how to integrate python and numpy into my preexisting application, I started a new Xcode project within the same kivy environment and used the following steps to set it up. I am able to run Python fine, but importing numpy gives me the errors specified by the stacktrace at the bottom of the post. The two projects appear identical to me, are pointing to the same code for their exterior libraries (numpy) as well as the same python code to run. The one set up with ./toolchain create works fine, but the one I set up independently does not.
// Move all the python files into your project directory
rsync -av --delete “{path to python code}”/ "$PROJECT_DIR"/YourApp
//Compile all the python code
{kivy project directory}/dist/hostpython/bin/python -OO -m compileall "$PROJECT_DIR"/YourApp
//Remove py and pyc files
find "$PROJECT_DIR"/YourApp/ -iname '*.py' -exec rm {} \; -or -iname '*.pyc' -exec rm {} \;
{kivy project directory}/dist/hostpython/include
{kivy project directory}/dist/root/python/lib
Below is my Python Stacktrace as well as the Kivy error messages used to
Traceback (most recent call last):
File "/Users/tommy/development/DiamondKinetics/python_tests/toolchain_testing/PythonGroundUp/YourApp/main.py", line 71, in <module>
File "/Users/tommy/development/DiamondKinetics/python_tests/toolchain_testing/build/numpy/i386/numpy-1.9.1/iosbuild/lib/python2.7/site-packages/numpy/__init__.py", line 170, in <module>
File "/Users/tommy/development/DiamondKinetics/python_tests/toolchain_testing/build/numpy/i386/numpy-1.9.1/iosbuild/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
File "/Users/tommy/development/DiamondKinetics/python_tests/toolchain_testing/build/numpy/i386/numpy-1.9.1/iosbuild/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
File "/Users/tommy/development/DiamondKinetics/python_tests/toolchain_testing/build/numpy/i386/numpy-1.9.1/iosbuild/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
File "/Users/tommy/development/DiamondKinetics/python_tests/toolchain_testing/build/numpy/i386/numpy-1.9.1/iosbuild/lib/python2.7/site-packages/numpy/core/__init__.py", line 6, in <module>
ImportError: dynamic module does not define init function (initmultiarray)
2017-08-23 16:24:57.607 PythonGroundUp[93146:2868366] Application quit abnormally!
2017-08-23 16:24:57.609 PythonGroundUp[93146:2868366] Leaving
The only difference that I can see is that the current working directory in the second project is simple “/” as opposed to “/Users/tommy/Library/Developer/CoreSimulator/Devices/36F3697E-733D-47A4-A1B0-2475216A402B/data/Containers/Bundle/Application/D8A12E3B-2752-49F8-9C05-44CD8949035F/test187.app/YourApp”. I tried to manually change the cwd location, but without success.
I put the kivy environment into a GitHub repo. The working Xcode project (created by ./toolchain.py create) is test187. PythonGroundUp is the one I created that is currently not working.
https://github.com/tdmartin4/kivy-ios
Thanks for any help you can give