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.


    Flask syntax error (possible installation issue)

    Pythonista
    flask
    3
    6
    6109
    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.
    • victordomingos
      victordomingos last edited by

      I want to try some stuff in flask, and I am stuck right at the beginning.

      I typed this in a new file:

      from flask import Flask
      
      app = Flask(__name__)
      

      And I get this error (running as python 3.5). If I try to run it as legacy python it does not raise this syntax error.

      Traceback (most recent call last):
        File "/private/var/mobile/Containers/Shared/AppGroup/5E22383E-122A-4BBE-9677-E4A0EF63E7C3/Pythonista3/Documents/flask-experiências/app.py", line 1, in <module>
          from flask import Flask
        File "/private/var/mobile/Containers/Shared/AppGroup/5E22383E-122A-4BBE-9677-E4A0EF63E7C3/Pythonista3/Documents/site-packages/flask/__init__.py", line 21, in <module>
          from .app import Flask, Request, Response
        File "/private/var/mobile/Containers/Shared/AppGroup/5E22383E-122A-4BBE-9677-E4A0EF63E7C3/Pythonista3/Documents/site-packages/flask/app.py", line 1264
          raise exc_type, exc_value, tb
                        ^
      SyntaxError: invalid syntax
      

      I am afraid I could have messed system packages while installing modules... Not sure if I tryed to pip install flask.

      Any ideas?

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

        when you use stash pip to install modules, it installes the 2.7 version. pythonista comes with flask installed, so just delete that folder from site packages,

        victordomingos 1 Reply Last reply Reply Quote 1
        • dgelessus
          dgelessus last edited by dgelessus

          After you delete the flask folder from your site-packages, you might need to restart Pythonista to make the import work again. Python caches imported modules internally, so sometimes you need to fully restart Python to clear old modules from the cache.

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

            @JonB I only work with Python 3. Is there a way to install new modules into Python 3?

            Also, is the bundled version of Flask compatible with Python 3?

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

              The version you have installed is version 0.7 or earlier. Pythonista comes installed with version 0.10.1. Current version is 0.12.x.

              The pythonista version is compatible with py3 ( as are current versions), so if you delete the version in site packages, you should be good to go with 0.10.

              If you need 0.12, pip install should work, but often requires some manual intervention. In this case, you just need to manually install the missing click dependency:

              pip install flask
              pip install click
              

              In other cases, with complex setup.py, you can pip download, then tar -xvzf then figure out what needs to be copied.

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

                Ok. Thanks. I have deleted that folder and it seems to work now.

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