Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS 6: libpython2.7.a initialization import error
    primarykey
    data
    text
    <p>Stuck on initialization Embedded Python on iOS. I took build script from Kivy project. It produced libpython2.7.a, Python27.zip and includes.</p> <p>So, my app unpacks zip to /Documents/lib/python2.7</p> <p>Trying to set up Python:</p> <pre><code>dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); docsDir = [dirPaths objectAtIndex:0]; Py_SetPythonHome((char *)[docsDir UTF8String]); Py_SetProgramName(""); Py_Initialize(); </code></pre> <p>Falls on:</p> <pre><code>ImportError: No module named site </code></pre> <p>As I understand, it cant locate Python home path. But if I fix site by:</p> <pre><code>Py_NoSiteFlag=1; PyRun_SimpleString("import sys as s\nprint(s.path)"); </code></pre> <p>It outputs valid pathes:</p> <pre><code>['/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python27.zip', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/plat-darwin', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/plat-mac', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/plat-mac/lib-scriptpackages', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/lib-tk', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/lib-old', '/var/mobile/Applications/1BC015FC-2F7A-41C0-8F3A-70A22510C3A3/Documents/lib/python2.7/lib-dynload'] </code></pre> <p>But no one import works. What I must fix to make Python correctly work with modules?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload