python - Flask 不会在 PythonAnywhere 中使用我已安装的模块
问题描述
我需要帮助了解这里出了什么问题。
我会尽力解释这一点,但我对 PythonAnywhere 有点陌生。我收到此错误:
Traceback (most recent call last):
File "/home/HelliottChip/mysite/app/__init__.py", line 6, in <module>
from flask_migrate import Migrate
ModuleNotFoundError: No module named 'flask_migrate'
尝试运行我的 main.py 文件时。但是我已经安装了它们,如下代码所示:
17:14 ~/.local/bin $ pip install Flask-SQLAlchemy email_validator flask-mail pyjwt flask-bootstrap flask-moment
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2
.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in links: /usr/share/pip-wheels
Requirement already satisfied: Flask-SQLAlchemy in /usr/local/lib/python2.7/dist-packages (2.4.1)
Requirement already satisfied: email_validator in /home/HelliottChip/.local/lib/python2.7/site-packages (1.1.2)
Requirement already satisfied: flask-mail in /usr/local/lib/python2.7/dist-packages (0.9.1)
Requirement already satisfied: pyjwt in /usr/local/lib/python2.7/dist-packages (1.7.1)
Requirement already satisfied: flask-bootstrap in /usr/local/lib/python2.7/dist-packages (3.3.7.1)
Requirement already satisfied: flask-moment in /home/HelliottChip/.local/lib/python2.7/site-packages (0.11.0)
Requirement already satisfied: Flask>=0.10 in /usr/local/lib/python2.7/dist-packages (from Flask-SQLAlchemy) (1.1.1)
Requirement already satisfied: SQLAlchemy>=0.8.0 in /usr/local/lib/python2.7/dist-packages (from Flask-SQLAlchemy) (1.3.10)
Requirement already satisfied: idna>=2.0.0 in /usr/local/lib/python2.7/dist-packages (from email_validator) (2.8)
Requirement already satisfied: dnspython>=1.15.0 in /home/HelliottChip/.local/lib/python2.7/site-packages (from email_validator) (1.16.0)
Requirement already satisfied: blinker in /usr/local/lib/python2.7/dist-packages (from flask-mail) (1.4)
Requirement already satisfied: dominate in /usr/local/lib/python2.7/dist-packages (from flask-bootstrap) (2.4.0)
Requirement already satisfied: visitor in /usr/local/lib/python2.7/dist-packages (from flask-bootstrap) (0.1.3)
Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (1.1.0)
Requirement already satisfied: Jinja2>=2.10.1 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (2.10.3)
Requirement already satisfied: click>=5.1 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (7.0)
Requirement already satisfied: Werkzeug>=0.15 in /usr/local/lib/python2.7/dist-packages (from Flask>=0.10->Flask-SQLAlchemy) (0.16.0)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib/python2.7/dist-packages (from Jinja2>=2.10.1->Flask>=0.10->Flask-SQLAlchemy) (0.23)
我已经浏览了所有可以找到的有关如何解决此问题的网站,但我迷路了。这是我在 Replit.com 上工作了一段时间的 Flask 应用程序,它运行良好,直到转移到 PythonAnywhere。我已经尝试了大约两个星期来解决这个问题^~^但仍然没有运气。我使用了很多本指南来帮助我,因为我也在练习我的 Web 部署技能。(不需要判断我正在使用烧瓶-3-)但是有人可以花时间帮助我吗?如果可以的话,非常感谢。
解决方案
检查您在 PythonAnywhere 上的 Web 应用程序是否设置为由 Python 2.7 运行——我看到您在pip install
虚拟环境之外使用,默认情况下它将使用 Python 2.7 的 pip,正如您在输出中看到的那样(顺便说一句。它赢了'不适用于 PythonAnywhere,您需要提供--user
选项)。如果要在虚拟环境之外为不同版本的 Python 安装包,请使用pipX.X install --user ...
(其中X.X
应替换为所需的 Python 版本)。此外,请记住每次更改设置时重新加载 Web 应用程序。如果你真的被卡住了,也许可以尝试联系 PythonAnywhere 支持 (support@pythonanywhere.com) 或使用他们的论坛?
推荐阅读
- python - Python 上的 Google 距离矩阵 API 非常慢
- python - 使用 glob 排除时间序列文件
- php - 登录尝试成功后 Auth::check() 返回 false
- ruby-on-rails - 为什么添加密码恢复后密码验证不起作用?
- codeigniter - CodeIgntier 3 使用本机会话而不是 CI 的驱动程序
- visual-studio - 安装 Visual Studio 扩展时缺少 Microsoft.VisualStudio.Component.CoreEditor
- azure-devops - 如何在 Azure Devops 中查找搁置集和分支之间的冲突
- c# - 数据库上的列名无效
- python - 如何在 python(pandas) 中保存数据
- python - ffmpeg 作为子进程需要太长时间