简体   繁体   English

在Heroku上部署Django应用时如何导入yaml

[英]How to import yaml when deploying Django app on Heroku

I have a working Django App but when I try to deploy it on Heroku I get this error: 我有一个运行中的Django应用程序,但是当我尝试在Heroku上部署它时,出现此错误:

Exception Type: ImportError Exception Value: 异常类型:ImportError异常值:
No module named yaml 没有名为yaml的模块

ImportError at /crunchApp/contact
No module named yaml
Request Method: GET
Request URL:    http://desolate-citadel-5832.herokuapp.com/crunchApp/contact
Django Version: 1.4.1
Exception Type: ImportError
Exception Value:    No module named yaml
Exception Location: /app/crunchApp/Crunch.py in <module>, line 10
Python Executable:  /app/.heroku/venv/bin/python
Python Version: 2.7.2
Python Path:    
['/app',
'/app/.heroku/venv/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg',
'/app/.heroku/venv/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
'/app',
 '/app/.heroku/venv/lib/python27.zip',
'/app/.heroku/venv/lib/python2.7',
'/app/.heroku/venv/lib/python2.7/plat-linux2',
'/app/.heroku/venv/lib/python2.7/lib-tk',
'/app/.heroku/venv/lib/python2.7/lib-old',
'/app/.heroku/venv/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk',
'/app/.heroku/venv/lib/python2.7/site-packages']
Server time:    Sat, 22 Sep 2012 20:35:34 -0700

I am not sure what I need to update since the line that is crashing it simply says this: 我不确定我需要更新什么,因为崩溃的行只是这样说:

import yaml

Thanks for the help!! 谢谢您的帮助!!

To expand on forvaidya's answer, yaml is missing from your requirements.txt file and that is why Heroku is not installing it when you commit your app. 为了进一步了解forvaidya的答案,在您的requirements.txt文件中缺少yaml ,这就是为什么在提交应用程序时Heroku没有安装它的原因。 In your base directory, rerun the following command to make this work: 在您的基本目录中,重新运行以下命令以使其工作:

pip freeze > requirements.txt
git add .
git commit -m "fixed requirements.txt file"

...then push back to Heroku. ...然后推回Heroku。

yaml模块不存在或不在路径中。

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

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