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.
Unable to launch_stash.py in pythonista 3 for IOS
I have an ipad pro 10.5 with IOS 11.1 and just downloaded pythonista 3. I want to import some libraries as netmiko with “pip install netmiko”. It appears the best way is with “stash”. So I imported stash with the script:
import requests as r; exec(r.get('http://bit.ly/get-stash').text)
However, when I try to launch “launch_stach.py” from my home directory I get an error on line 28 “from stash import stash” that says “not well-formed (invalid token). Please, check snapshot attached.
If I try to go to “site-packages” —> “stash” and then execute “stash.py” I get an error “No module named “configParser”.
Of course, I tryed to restart pythonista 3 but it didn’t fix the issue.
Could someone please help?
ccc last edited by ccc
You could try copying the first line of the first script (#!python2) and pasting that in as the first line of the second file and then rerunning the second file. It is my undersstanding that StaSH must run under Python 2 and your error message gives me the impression that you are running under Python 3.
Hello @ccc , thans for your response.
Pythonista 3 is able to run the scripts either with « python 2 » or « python 3 », I tried both with the same result. I tryed to remove « stash » and reinstall it », « force quit » pythonista, etc... but no success.
What do you mean by copying the first line of the first script and pasting on the second one? Could you be more precise on what I need to do please? (What exactly to copy, where exactly to paste...)
I don’t really know what to do...and without pip pythonista 3 is useless for me...
Here below a screenshot with the result of the of Traceback button...maybe it helps...
When running with Python 2.7, the error message is slight different. Here below:
- What pythonista version are you using? The latest app store version, or the beta?
- The parse error indicates that your Info.plist is corrupted. You should try removing/reinstalling pythonista. If you have pythonista 2.0 installed, you won't lose any files, otherwise you need to back up first.
- The ConfigParser error is because you are running stash with python 3.x -- stash is only compatible with python 2.x (which is why launch_stash has the #!python2 at the start.
- As a workaround, you could also comment out the offending line from shcommon.py, and just set
(thats from the beta, but it does not really matter as long as the version is > 3.0)
one more thing to look at before reinstalling pythonista:
import sys, os print(open(os.path.join(os.path.dirname(sys.executable), 'Info.plist')).readline())
you also never said what device /os versionyou are using -- has ios started switching over to binary Info.plists?
Hi @JonB ,
I appreciate your help and I hope we will find the solution soon as I can’t wait to develop some stuff in Pythonista...
Here is the Info that I thought I already said:
- Ipad 10.5
- IOS 11.1
- Pythonista 3.0 version
I reinstalled Pythonista and then first thing I did is to download “stash”, then I ran “launch_stash.py” with version python 2.7 but still....same error.
I also tryed to run what you asked, here is the output:
I tried to change what you suggested in “shcommon.py” but it didn’t fix anything:
dgelessus last edited by dgelessus
@siulman Can you try running this and post the output:
import sys, os print(repr(open(os.path.join(os.path.dirname(sys.executable), 'Info.plist'), 'rb').read(256)))
@JonB I have an idea what the issue could be. Pythonista's
Info.plistmight be a binary plist (rather than XML) in the current App Store version of Pythonista. The Python 2 version of
plistlibonly supports XML plists I think. The Python 3 version supports both and detects the format automatically.
yeah, binary plist is what i was thinking. (I think it must be an ios 11 thing?)
The solution in 2.7 would then be maybe to use objc rather than plistlib:
from objc_util import NSBundle PYTHONISTA_VERSION=str(NSBundle.mainBundle().objectForInfoDictionaryKey('CFBundleShortVersionString')) PYTHONISTA_VERSION_LONG=str(NSBundle.mainBundle().objectForInfoDictionaryKey('CFBundleVersion')) if PYTHONISTA_VERSION < '3.0': ....
@dgelessus here is the output you requested:
@JonB Any workaroung you come up with to make that work?
dgelessus last edited by
@JonB What exactly does Stash use the Pythonista version number for? If you only need to know whether you're in Pythonista 3 or not, you could probably check
sys.executable.endswith("3")instead, or see whether
Py3Kit.frameworkexists or not.
I think it just uses it to report version # at startup, and check for pythonista 3.
The code I posted above should work, in shcommon.py. objc_util is probably overkill, but already imported for stash.
I modifyed the “shcommon.py” according to the @JonB suggestions and it worked.
I was also able to “pip install netmiko” and connect to my switches to execute the commands I wanted to. I am really happy now! Thanks!
Here below snapshots.
I think this should be taken into account for a new release of the app?
Thank you very much for your help @JonB as long as @dgelessus
if you'd like. you can submit a pull request over on the stash github page. If not, I will do it this week.
helixgreen last edited by
I ran into the same problem today. After reading through this thread I realized perhaps it had to do with having both Pythonista 2 and the new Pythonista 3 installed. I uninstalled both and reinstalled 3 and it fixed the problem.