简体   繁体   English

将我的 Flask 应用程序克隆到我的新计算机后,我无法运行它

[英]After cloning my Flask app to my new computer I can not get it to run

I am building a Flask app to create a peer to peer market place.我正在构建一个 Flask 应用程序来创建一个点对点市场。 I am having trouble getting the code running on my new computer.我在新计算机上运行代码时遇到问题。 The code can be found here: https://github.com/ripemelon/flaskbyge .代码可以在这里找到: https : //github.com/ripemelon/flaskbyge

flaskbyge$ python run.py
/home/byge/.local/lib/python2.7/site-packages/flask_sqlalchemy/__init__.py:834: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
  'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
Traceback (most recent call last):
  File "run.py", line 1, in <module>
    from flaskbyge import app
  File "/home/byge/Desktop/flaskbyge/flaskbyge/__init__.py", line 15, in <module>
    from flaskbyge import routes
  File "/home/byge/Desktop/flaskbyge/flaskbyge/routes.py", line 33
    flash(f'Account created for {form.username.data}! You can now log in','success' )***

It gives me this error when I try to run the Flask module using the SQLAlchemy database.当我尝试使用 SQLAlchemy 数据库运行 Flask 模块时,它给了我这个错误。

You are using Python2.7 as you can see in the first line of your error message.正如您在错误消息的第一行中看到的那样,您正在使用 Python2.7。 It seems that this app is developed for at least Python3.6, because formatted strings are used as you can see in the last line ( flash(f'Account ...) ).似乎这个应用程序至少是为 Python3.6 开发的,因为正如您在最后一行( flash(f'Account ...) )中看到的那样,使用了格式化的字符串。

This works for me:这对我有用:

$ cd $ROOT_FOLDER_OF_YOUR_APP
$ python3.8 -m venv flaskbyge
$ source flaskbyge/bin/activate
$ pip install -r requirements.txt
$ python run.py

For me python3.8 is clearly running the Python3.8 interpreter.对我来说, python3.8显然是在运行 Python3.8 解释器。 The command can be different for you, maybe python3 or similar.该命令对您来说可能不同,可能是python3或类似的。 Maybe Python3.6 is enough.也许Python3.6就足够了。 Note, that after activating the virtual environment, the python and pip command refers to the right Python version (here Python3.8).注意,激活虚拟环境后, pythonpip命令指的是正确的 Python 版本(这里是 Python3.8)。

All after all, it seems that you only have to ensure that you don't start the app via Python2.7.毕竟,看起来你只需要确保你不通过Python2.7启动应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM