1

我在 iOS 上使用 Pythonista 应用程序,即使使用最基本的代码也无法使 Flask 模块工作。

我的代码是:

from flask import Flask

Flaskapp = Flask(__name__)

@Flaskapp.route('/')
def helloWorld():
  return 'Woala'

Flaskapp.run(debug=True)

但继续收到:

* Serving Flask app "app" (lazy loading)
* Environment: production
  WARNING: This is a development server. Do not use it in a production deployment.
  Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
Traceback (most recent call last):
 File "/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/app.py", line 9, in <module>
   Flaskapp.run(debug=True)
 File "/private/var/mobile/Containers/Shared/AppGroup/C4F03A05-D634-4F19-865F-6072E8D6DC38/Pythonista3/Documents/site-packages-3/flask/app.py", line 990, in run
   run_simple(host, port, self, **options)
 File "/private/var/mobile/Containers/Shared/AppGroup/C4F03A05-D634-4F19-865F-6072E8D6DC38/Pythonista3/Documents/site-packages-3/werkzeug/serving.py", line 1007, in run_simple
   run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
 File "/private/var/mobile/Containers/Shared/AppGroup/C4F03A05-D634-4F19-865F-6072E8D6DC38/Pythonista3/Documents/site-packages-3/werkzeug/_reloader.py", line 332, in run_with_reloader
   sys.exit(reloader.restart_with_reloader())
 File "/private/var/mobile/Containers/Shared/AppGroup/C4F03A05-D634-4F19-865F-6072E8D6DC38/Pythonista3/Documents/site-packages-3/werkzeug/_reloader.py", line 176, in restart_with_reloader
   exit_code = subprocess.call(args, env=new_environ, close_fds=False)
 File "/var/containers/Bundle/Application/E373BC34-F149-4EF5-9D0E-5CD807AB0771/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 268, in call
   with Popen(*popenargs, **kwargs) as p:
 File "/var/containers/Bundle/Application/E373BC34-F149-4EF5-9D0E-5CD807AB0771/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 708, in __init__
   restore_signals, start_new_session)
 File "/var/containers/Bundle/Application/E373BC34-F149-4EF5-9D0E-5CD807AB0771/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/subprocess.py", line 1261, in _execute_child
   restore_signals, start_new_session, preexec_fn)
PermissionError: [Errno 1] Operation not permitted

我已经在 launch_stash.py 中安装了烧瓶槽 pip

4

3 回答 3

4

我在另一个论坛上收到了用户 augusto 的解决方案,所以我相信它也值得在这里分享,因为它运行良好。

“使用调试的唯一方法是:

if __name__ == '__main__':
    app.run(use_reloader=False, debug=True)”

https://forum.omz-software.com/topic/5758/pythonista-flask-error-errno-1

于 2019-07-28T01:35:30.803 回答
2

iOS 沙箱有一些限制,会阻止您创建子进程

烧瓶开发服务器正在尝试创建一个子进程来检测代码更改,然后在您进行更改时重新加载服务器。您可以通过传递 "--no-reload" 来禁用它flask run --no-reload。这意味着您必须在进行更改时手动重新启动开发服务器

于 2019-07-27T22:44:38.800 回答
1

将 Pythonista 的默认解释器更改为 Python 2.7。

于 2020-03-01T04:12:23.637 回答