-
-
Notifications
You must be signed in to change notification settings - Fork 328
Missing modules for flask backend #1104
-
Current Situation
reactpy/backend/flask.py
ModuleNotFoundError: No module named 'flask_cors'
ModuleNotFoundError: No module named 'flask_sock'
I tried to deploy in GCP.
Proposed Actions
No response
Beta Was this translation helpful? Give feedback.
All reactions
You need to pip install reactpy[flask].
Replies: 5 comments 3 replies
-
You need to pip install reactpy[flask].
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks, is this documented elsewhere?
I read running reactpy in production but it is not there.
Beta Was this translation helpful? Give feedback.
All reactions
-
It is within the installation docs
Beta Was this translation helpful? Give feedback.
All reactions
-
I put reactpy[flask] in requirements.txt
After
pip install -r requirements.txt
from GCP cloud shell, I got this error and warning.
ERROR: Command errored out with exit status 1:
command: /home/xxxx/yyyy/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oo12x6rg/flask_0df81e498beb43ea800714e7585a72fa/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oo12x6rg/flask_0df81e498beb43ea800714e7585a72fa/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-m90xuwv9
cwd: /tmp/pip-install-oo12x6rg/flask_0df81e498beb43ea800714e7585a72fa/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-oo12x6rg/flask_0df81e498beb43ea800714e7585a72fa/setup.py", line 62
print "Audit requires PyFlakes installed in your system."
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Audit requires PyFlakes installed in your system.")?
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/49/0a/fe5021b35436202d3d4225a766f3bdc7fb51521ad89e73c5162db36cdbc7/Flask-0.9.tar.gz#sha256=2fd5d4ffe81f762dd2a3e58472d690a0dbba3766776506003aee3ed7aaa8afef (from https://pypi.org/simple/flask/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached Flask-0.8.1.tar.gz (458 kB)
ERROR: Command errored out with exit status 1:
command: /home/xxxx/yyyy/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oo12x6rg/flask_5bbe7300123e4aca886a1bf6911c8268/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oo12x6rg/flask_5bbe7300123e4aca886a1bf6911c8268/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ecmqcogt
cwd: /tmp/pip-install-oo12x6rg/flask_5bbe7300123e4aca886a1bf6911c8268/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-oo12x6rg/flask_5bbe7300123e4aca886a1bf6911c8268/setup.py", line 62
print "Audit requires PyFlakes installed in your system."""
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Audit requires PyFlakes installed in your system.""")?
----------------------------------------
more ...
Using cached Flask-0.6.1.tar.gz (413 kB)
Using cached Flask-0.6.tar.gz (388 kB)
Using cached Flask-0.5.2.tar.gz (369 kB)
Using cached Flask-0.5.1.tar.gz (369 kB)
Using cached Flask-0.5.tar.gz (369 kB)
Using cached Flask-0.4.tar.gz (352 kB)
Using cached Flask-0.3.1.tar.gz (339 kB)
Using cached Flask-0.3.tar.gz (1.0 MB)
Using cached Flask-0.2.tar.gz (13 kB)
Using cached Flask-0.1.tar.gz (9.2 kB)
Collecting Werkzeug>=2.3.0
Using cached Werkzeug-2.3.2-py3-none-any.whl (242 kB)
Using cached Werkzeug-2.3.1-py3-none-any.whl (242 kB)
Using cached Werkzeug-2.3.0-py3-none-any.whl (233 kB)
INFO: pip is looking at multiple versions of click to determine which version is compatible with other requirements. This could take a while.
Collecting Werkzeug>=2.2.2
Using cached Werkzeug-2.2.3-py3-none-any.whl (233 kB)
Using cached Werkzeug-2.2.2-py3-none-any.whl (232 kB)
Collecting Jinja2>=3.0
Using cached Jinja2-3.1.1-py3-none-any.whl (132 kB)
Using cached Jinja2-3.1.0-py3-none-any.whl (132 kB)
Using cached Jinja2-3.0.3-py3-none-any.whl (133 kB)
Using cached Jinja2-3.0.2-py3-none-any.whl (133 kB)
Using cached Jinja2-3.0.1-py3-none-any.whl (133 kB)
Using cached Jinja2-3.0.0-py3-none-any.whl (133 kB)
Collecting itsdangerous>=2.0
Using cached itsdangerous-2.1.1-py3-none-any.whl (15 kB)
...
I cancelled as it is taking too much time.
Beta Was this translation helpful? Give feedback.
All reactions
-
Perhaps this is caused by an incompatible python version. Try changing to Python 3.9 or 3.10.
The logs suggest you're trying to run code that was designed for a Python 2 environment.
Beta Was this translation helpful? Give feedback.
All reactions
-
The installed python is 'Python 3.9.2'
Beta Was this translation helpful? Give feedback.
All reactions
-
Be noted that If I use:
pip install reactpy
pip install Flask
pip install Flask-Cors
pip install flask-sock
It will work.
Beta Was this translation helpful? Give feedback.
All reactions
-
I finally got it to work.
The app yaml file is using flexible environment. Using standard environment does not work so far.
app.yaml
runtime: python # F1 = 2 workers (default), F2 = 4 workers instance_class: F1 env: flex # -w 2 sets gunicorn number of workers # The number of workers you specify should match the instance class of your App Engine app: entrypoint: gunicorn -b :$PORT -w 2 main:app runtime_config: operating_system: "ubuntu22" runtime_version: "3.11"
main.py
from reactpy import component, html from reactpy.backend.flask import configure from flask import Flask @component def HelloWorld(): return html.h1("Hello, world!") app = Flask(__name__) configure(app, HelloWorld)
requirements.txt
Flask
reactpy
gunicorn
Flask-Cors
flask-sock
Deploy command.
gcloud app deploy app.yaml
An example is in my rflask repo.
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 1 -
🚀 1