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?
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:
@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?
@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 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?
if you'd like. you can submit a pull request over on the stash github page. If not, I will do it this week.
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.