omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Unable to launch_stash.py in pythonista 3 for IOS

    Pythonista
    pythonista 3 stash
    5
    15
    14498
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • siulman
      siulman last edited by

      Hello guys,

      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.
      bb5b68a6-45fa-4eb6-8320-7d1ee4825149

      If I try to go to “site-packages” —> “stash” and then execute “stash.py” I get an error “No module named “configParser”.

      0f9f5d83-3e59-4b61-ab67-5424c96be0bd

      Of course, I tryed to restart pythonista 3 but it didn’t fix the issue.

      Could someone please help?

      1 Reply Last reply Reply Quote 0
      • ccc
        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.

        1 Reply Last reply Reply Quote 0
        • siulman
          siulman last edited by

          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...

          Thanks!

          Here below a screenshot with the result of the of Traceback button...maybe it helps...

          613d4980-f959-4ab0-9306-6fdd5ec11bc2

          1 Reply Last reply Reply Quote 0
          • siulman
            siulman last edited by

            When running with Python 2.7, the error message is slight different. Here below:

            c6964961-0a2e-445f-8e0d-6cf30bf9f1d8

            1 Reply Last reply Reply Quote 0
            • JonB
              JonB last edited by

              1. What pythonista version are you using? The latest app store version, or the beta?
              2. 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.
              3. 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.
              4. As a workaround, you could also comment out the offending line from shcommon.py, and just set
              PYTHONISTA_VERSION='3.1.1'
              PYTHONISTA_VERSION_LONG='311016'
              

              (thats from the beta, but it does not really matter as long as the version is > 3.0)

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                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?

                1 Reply Last reply Reply Quote 0
                • siulman
                  siulman last edited by siulman

                  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:

                  7793ae5c-211f-4a3e-b8a1-e99cfbabb146

                  I tried to change what you suggested in “shcommon.py” but it didn’t fix anything:

                  7ec15fb6-a2ff-4693-a365-ffb159c94f75

                  Thank you

                  1 Reply Last reply Reply Quote 0
                  • dgelessus
                    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.plist might be a binary plist (rather than XML) in the current App Store version of Pythonista. The Python 2 version of plistlib only supports XML plists I think. The Python 3 version supports both and detects the format automatically.

                    1 Reply Last reply Reply Quote 0
                    • JonB
                      JonB last edited by

                      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:

                      if IN_PYTHONISTA:

                      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':
                      ....
                      
                      1 Reply Last reply Reply Quote 0
                      • siulman
                        siulman last edited by siulman

                        Appreciated guys...
                        @dgelessus here is the output you requested:

                        b259d311-7b4e-4c24-9ab8-1d7e8e34d2ad

                        @JonB Any workaroung you come up with to make that work?

                        1 Reply Last reply Reply Quote 0
                        • dgelessus
                          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.framework exists or not.

                          1 Reply Last reply Reply Quote 0
                          • JonB
                            JonB last edited by

                            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.

                            1 Reply Last reply Reply Quote 0
                            • siulman
                              siulman last edited by siulman

                              Hello guys,

                              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

                              96bbe954-86de-4a66-b8af-c15a5430fbbf
                              a22d32a4-f623-4bf2-aa3e-7ea04b073ea4

                              1 Reply Last reply Reply Quote 1
                              • JonB
                                JonB last edited by

                                if you'd like. you can submit a pull request over on the stash github page. If not, I will do it this week.

                                1 Reply Last reply Reply Quote 0
                                • helixgreen
                                  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.

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post
                                  Powered by NodeBB Forums | Contributors