Skip to content
← Back to Community
Can't import fLASK
Profile icon
romainkarpinski

Hi, when i try to import flask, it says that the current flask version is not compatible with the current repl version.. what should i do? is it possible to fix this? ty for your help

Voters
Profile icon
YusufKAHRAMAN
Profile icon
romainkarpinski
Comments
hotnewtop
Profile icon
Coder100

try deleting these files and installing again

image

image

Profile icon
xfinnbar

THe replit package includes it's own Flask fork. Instead of using from flask import Flask use from replit.web import App and use app = App(__name__) instead of app = Flask(__name__). This flask fork adds a few new features like login with replit for your site. See its docs here https://replit-py.readthedocs.io/en/latest/index.html

Profile icon
romainkarpinski

@xfinnbar it fixed most of my problems ty, but now i get this error mesage: ValueError: signal only works in main thread .. How can i fix this?

Profile icon
xfinnbar

@romainkarpinski What line? What file?

Profile icon
romainkarpinski

@xfinnbar File "/usr/lib/python3.8/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler)), this is the last file mentionned in the log before the error message

Profile icon
romainkarpinski

@xfinnbar full log:

  • Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
    Exception in thread Thread-1:
    Traceback (most recent call last):
    File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
    File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
    File "/home/runner/BOT/keep_alive.py", line 11, in run
    app.run()
    File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/web/app.py", line 147, in run
    super().run(host="localhost" if localhost else "0.0.0.0", port=port, **kwargs)
    File "/opt/virtualenvs/python3/lib/python3.8/site-packages/flask/app.py", line 990, in run
    run_simple(host, port, self, **options)
    File "/opt/virtualenvs/python3/lib/python3.8/site-packages/werkzeug/serving.py", line 1050, in run_simple
    run_with_reloader(inner, extra_files, reloader_interval, reloader_type)
    File "/opt/virtualenvs/python3/lib/python3.8/site-packages/werkzeug/_reloader.py", line 330, in run_with_reloader
    signal.signal(signal.SIGTERM, lambda *args: sys.exit(0))
    File "/usr/lib/python3.8/signal.py", line 47, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
    ValueError: signal only works in main thread
Profile icon
xfinnbar

@romainkarpinski I forked the repl and fixed it, copy across my pyproject.toml file and keep_alive.py file. https://replit.com/@xfinnbar/BOT#keep_alive.py

Profile icon
romainkarpinski

@xfinnbar it works perfectly, ty so much for helping me :)

Profile icon
IOP3

rlly? just import it like from flask import Flask? is it not working?

Profile icon
romainkarpinski

@IOP3 No... and i don't know why..

Profile icon
romainkarpinski

@IOP3 Because replit (3.0.0) depends on flask (>=1.1.2,<2.0.0)
and no versions of replit match >3.0.0,<4.0.0, replit (>=3.0.0,<4.0.0) requires flask (>=1.1.2,<2.0.0).
So, because repl-python3-bot depends on both replit (^3.0.0) and flask (^2.0.0), version solving failed.
exit status 1

Profile icon
romainkarpinski

@IOP3thats the error message