【发布时间】:2018-08-21 12:31:37
【问题描述】:
我刚刚将我的应用程序部署到 Heroku,打开应用程序时出现错误,它显示:“ModuleNotFoundError: No module named 'crispy_forms'”,MultiSelectField 也是如此。
我曾尝试在平台的控制台中安装这些包,但似乎没有效果,每次运行“heroku run pip freeze”时都会得到相同的包。
我尝试在本地控制台中运行以下命令:
heroku run bash
pip install django-crispy-forms
pip install django-multiselectfield
pip freeze # To check if the packages where installed
然后我发现一切似乎都很好,django-crispy-forms 和 django-multiselectfield 出现在“pip freeze”命令的包列表中,但是当我签入平台时,更新不存在。
如下所示,我在根文件夹中添加了“requirements.txt”文件,以及 Pipfile、Procfile。
“requirements.txt”文件添加了代码 pip freeze > requirements.txt:
argon2-cffi==18.1.0
bcrypt==3.1.4
certifi==2018.4.16
cffi==1.11.5
chardet==3.0.4
dj-database-url==0.4.2
Django==2.0
django-crispy-forms==1.7.2
-e git://github.com/AndrewIngram/django-extra-
views.git@aa58167af84d89feea286f9567a72cc5941360e4#egg=django_extra_views
django-heroku==0.1.0
django-multiselectfield==0.1.8
django-session-timeout==0.0.3
gunicorn==19.7.1
idna==2.7
mailsnake==1.6.4
numpy==1.14.5
pandas==0.23.3
Pillow==5.2.0
pipenv==2018.5.18
psycopg2==2.7.3.2
pycparser==2.18
python-dateutil==2.7.3
pytz==2017.3
requests==2.19.1
six==1.11.0
stripe==2.4.0
urllib3==1.23
virtualenv==16.0.0
virtualenv-clone==0.3.0
whitenoise==3.3.1
我的 Pipfile 如下:
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
[packages]
django = "*"
gunicorn = "*"
django-heroku = "*"
django-crispy-forms = "*"
django-multiselectfield = "*"
[requires]
python_version = "3.6"
我的 git push heroku master 的输出如下:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 711 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: Skipping installation, as Pipfile.lock hasn't changed since
last
deploy.
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 156.9M
remote: -----> Launching...
remote: Released v14
remote: https://blooming-headland-56472.herokuapp.com/ deployed to
Herok
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/blooming-headland-56472.git
d4535c9..5966fd9 master -> master
【问题讨论】: