简体   繁体   中英

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:

Exception Type: ImportError Exception Value:
No module named 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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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