Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Appex and user modules
-
Hi,
I have created a Python file "ftpx.py" containing only one class which I want to use in several programs. I have stored the file in site-packages. A standard program which imports this file using "from ftpx import FTPx" works fine. An extension program quits with "ImportError: No module named ftpx" as soon as I call it using the appex functionality. What could be the reason? How can I import my own functions also in appex programs?
Stefan
-
Importing modules from
site-packages
in the app extension works fine for me.Do you have both Pythonista 2 and 3 installed? If so, you might be using the wrong app extension - both are just called "Run Pythonista Script", but Pythonista 3's has a little 3 in the icon. To be sure, scroll all the way to the right, tap the three dots icon, and enable both Pythonista extensions and put them next to each other. Then you can easily see the difference.
-
I had Pythonista 2 installed before I changed to 3, but now I have installed only 3. I have created some test files. This one is the extension:
try: import test23 except: print('test23 not found') try: import test2 except: print('test2 not found') try: import test3 except: print('test3 not found')
These are test files located in site-packages and so on...
print('test23 found in site-packages')
print('test2 found in site-packages-2')
print('test3 found in site-packages-3')
When I start the extension from Pythonista I get this result when using Python 2.7:
test23 found in site-packages
test2 found in site-packages-2
test3 not foundand this one for Python 3.5:
test23 found in site-packages
test2 not found
test3 found in site-packages-3Called as extension I get:
test23 not found
test2 not found
test3 not found -
Got it! It works only when using Python 3, either by setting the default to 3.5 or using the shebang #!python3 to override the default interpreter which is set to 2.7 in my case.
Is this a bug or a feature? ;-)
-
Folks wanted both Python 2 and Python 3 in the same app, so it's a feature.
-
Yes it's a bug an extension should still import following how it normally does.