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.


    [Solved]ImportError when importing Images, Twitter and more

    Pythonista
    python-future twitter error import importerror
    4
    13
    9344
    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.
    • uj_jonas
      uj_jonas last edited by uj_jonas

      I installed @bear's python-twitter https://github.com/bear/python-twitter with stash like this pip install python-twitter

      I should of course have just looked for a Twitter module in the pythonista documentation, which I did after installing python-twitter and realized I should just use that.

      There was just one problem:
      import twitter

      raised the following error:

      ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
      

      This doesn't just happen when I import twitter, but also with Images, when I run my script the uploads pictures to Imgur and when I open the pythonista 3 widget from the share menu.

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

        The problem that you have is that Pythonista already comes with a module built in that you access with import twitter and then you installed a second, different module that you also access with import twitter. You now have a namespace collision and those two modules are colliding in ways that might be difficult to disentangle.

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

          Yes, I thought it was something like that :/

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

            But why does this affect other modules?

            1 Reply Last reply Reply Quote 0
            • uj_jonas
              uj_jonas @ccc last edited by

              @ccc and now it raised a new error
              module "copyreq" has no attribute "pickle"

              Damn I wish there was a undo button in stash

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

                Anything you installed in stash can be found by going to

                cd ~/Documents/site-packages
                

                then, if you find a folder you don't want, simply delete it

                rm -rf twitter
                

                if you have already imported the module, force quit pythonista, then restart, and you should be good to go.

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

                  @JonB didn't quite work.
                  I did remove the twitter folder, but now it's just back to the first error.
                  And I'm still wondering why this affects other modules. The ImportError says I'm either running Python-future from the src folder or it's corrupted, it think it's corrupted

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

                    So, to be clear:
                    if you type
                    import twitter in the console, running the 3.5 interpreter, you get that error?

                    What about from the 2.7 interpreter.

                    Make sure you don't have another twitter.py somewhere...

                    import twitter
                    twitter.file
                    '/var/mobile/Containers/Bundle/Application/4F1ECB6D-347F-4B3F-870B-9156A42DBDB0/Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/site-packages/twitter.py'

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

                      oh, the problem is that python twitter also installed future, since stash runs py2.7.

                      Delete future from site packages as well

                      uj_jonas 2 Replies Last reply Reply Quote 0
                      • uj_jonas
                        uj_jonas @JonB last edited by uj_jonas

                        @JonB future is now gone.

                        All I'm doing is
                        import twitter
                        It doesn't work in 3.5
                        It works in 2.7

                        From the console(2.7):

                        >>> import twitter
                        >>> twitter.__file__
                        '/var/containers/Bundle/Application/05B93F09-B103-44A6-9622-55237A53AC5E/Pythonista3.app/Frameworks/PythonistaKit.framework/pylib/site-packages/twitter.py'
                        
                        1 Reply Last reply Reply Quote 0
                        • uj_jonas
                          uj_jonas @JonB last edited by

                          @JonB is everything in site-packages what stash has installed?
                          If so, wouldn't trashing it all fix the problem?

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

                            @uj_jonas yes, stash saves packages installed via pip to the site-packages folder, but I wouldn't delete everything. Just look if there is a folder named Twitter in site-packages And try renaming/deleting that one

                            uj_jonas 1 Reply Last reply Reply Quote 0
                            • uj_jonas
                              uj_jonas @lukaskollmer last edited by

                              @lukaskollmer I got it all working again, except imgurpython.
                              I removed it from site-packages and tried to reinstall it with pip, but it wouldn't let me.

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