如何在Heroku上部署python模块?

假设您已经设置了Python 3.6,则在本地安装Pipenv和heroku CLI,并使用以下提到的步骤从CLI登录Heroku:https : //devcenter.heroku.com/articles/getting-started-with-python#set -向上。

您的应用程序需要有一个git存储库才能部署到heroku。您需要在git repo代码根目录所在的目录中cd。现在,您需要使用以下命令创建一个heroku应用程序:

$ heroku create
Creating lit-bastion-5032 in organization heroku... done, stack is cedar-14

http://lit-bastion-5032.herokuapp.com/ | https://git.heroku.com/lit-bastion-5032.git

Git remote heroku添加了

创建应用程序时,还将创建一个git远程(称为heroku)并将其与本地git存储库相关联。Heroku为您的应用程序生成一个随机名称(在本例中为lit-bastion-5032),或者您可以传递一个参数来指定您自己的应用程序名称。

现在已经添加了一个遥控器,您可以使用以下命令将代码推送到heroku:

$ git push heroku master
Counting objects: 232, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (217/217), done.
Writing objects: 100% (232/232), 29.64 KiB | 0 bytes/s, done.
Total 232 (delta 118), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.6.0
remote: -----> Installing requirements with latest pipenv...
remote:        Installing dependencies from Pipfile.lock...
remote:      $ python manage.py collectstatic --noinput
remote:        58 static files copied to '/app/gettingstarted/staticfiles', 58 post-processed.
remote:
remote: -----> Discovering process types
remote:        Procfile declares types -> web
remote:
remote: -----> Compressing...
remote:        Done: 39.3M
remote: -----> Launching...
remote:        Released v4
remote:        http://lit-bastion-5032.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To git@heroku.com:lit-bastion-5032.git
 * [new branch]      master -> master
Note that you need to specify your requirements(third party modules you are importing) with their version numbers(or without if you need latest one) in the requirements.txt. For example,
Flask==0.8
Jinja2==2.6
Werkzeug==0.8.3
certifi==0.0.8
chardet==1.0.1

您可以在heroku python文档上阅读有关此内容的更多信息:https ://devcenter.heroku.com/articles/python-pip