简体   繁体   English

在Heroku上用Python安装flask

[英]installing flask in Python on Heroku

I'm trying to follow this guide . 我正在尝试遵循本指南 I made virtualenv and installed flask in it: 我制作了virtualenv并在其中安装了flask

Requirement already satisfied (use --upgrade to upgrade): Flask in     /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in   /usr/local/lib/python2.7/dist-packages (from Flask)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in /usr/local/lib/python2.7/dist-packages (from Flask)

After pip freeze > requirements.txt the file contains only: pip freeze > requirements.txt该文件仅包含:

argparse==1.2.1
distribute==0.6.28
wsgiref==0.1.2

And there is no Flask package. 而且没有Flask包。 I'm trying to run simple example and got: 我正在尝试运行简单的示例并得到:

ImportError: No module named flask

How to install the package properly? 如何正确安装包?

You need to run pip freeze > reuirements.txt inside your virtualenv. 你需要在virtualenv中运行pip freeze > reuirements.txt Thus, make sure that your virtualenv was activated correctly. 因此,请确保您的virtualenv已正确激活。 As the Heroku documentation is mostly written from Linux point of view, this may be a little tricky especially on Windows (see a related question ): 由于Heroku文档主要是从Linux的角度编写的,所以这可能有点棘手,特别是在Windows上(参见相关问题 ):

  • Windows command-prompt activation is done using venv\\Scripts\\activate.bat 使用venv\\Scripts\\activate.bat完成Windows命令提示符venv\\Scripts\\activate.bat
  • If you are using Windows PowerShell, you need to run venv\\Scripts\\activate.ps1 instead. 如果您使用的是Windows PowerShell,则需要运行venv\\Scripts\\activate.ps1

Note that you need to activate virtualenv for sudo as well. 请注意,您还需要为sudo激活virtualenv。 Example: 例:

sudo bash
source venv/bin/activate
pip install Flask

However one of the points in virtualenv is that you don't need sudo. 然而,virtualenv中的一点是你不需要sudo。 Thus, you could simply omit using sudo and simply just run: 因此,你可以简单地省略使用sudo,只需运行:

source venv/bin/activate
pip install Flask

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

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