将Django项目推送到Heroku时出错
我已经尝试了一个小时来解决这个错误,但我已经没有办法了,所以请帮帮我。
heroku create
这个命令运行得很好,没有问题。
git push heroku master
Counting objects: 119, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (118/118), done.
Writing objects: 100% (119/119), 1.39 MiB | 66 KiB/s, done.
Total 119 (delta 4), reused 0 (delta 0)
-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.3.
-----> Preparing Python runtime (python-2.7.3)
-----> Installing Distribute (0.6.34)
-----> Installing Pip (1.2.1)
-----> Installing dependencies using Pip (1.2.1)
Downloading/unpacking Django==1.4.3 (from -r requirements.txt (line 1))
Running setup.py egg_info for package Django
Downloading/unpacking dj-database-url==0.2.1 (from -r requirements.txt (line 2))
Downloading dj-database-url-0.2.1.tar.gz
Running setup.py egg_info for package dj-database-url
Downloading/unpacking psycopg2==2.4.6 (from -r requirements.txt (line 3))
Running setup.py egg_info for package psycopg2
no previously-included directories found matching 'doc/src/_build'
Downloading/unpacking virtualenv==1.8.4.post1 (from -r requirements.txt (line 4))
Could not find a version that satisfies the requirement virtualenv==1.8.4.post1 (from -r requirements.txt (line 4)) (from versions: )
No distributions matching the version for virtualenv==1.8.4.post1 (from -r requirements.txt (line 4))
Storing complete log in /app/.pip/pip.log
! Heroku push rejected, failed to compile Python app
To git@heroku.com:[blocked].git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:[blocked].git'
需求文件:
>Django==1.4.3
>dj-database-url==0.2.1
>psycopg2==2.4.6
>virtualenv==1.8.4.post1
进程文件:
web: python manage.py runserver 0.0.0.0:$PORT --noreload
Heroku 日志:
The 'heroku' gem has been deprecated and replaced with the Heroku Toolbelt, download and install from https://toolbelt.heroku.com.
2013-01-24T01:22:06+00:00 heroku[api]: Enable Logplex by [private email]@yahoo.com
2013-01-24T01:22:06+00:00 heroku[api]: Release v2 created by [private email]@yahoo.com
2013-01-24T01:22:42+00:00 heroku[slugc]: Slug compilation started
2013-01-24T01:23:38+00:00 heroku[slugc]: Slug compilation failed: failed to compile Python app
2013-01-24T01:43:26+00:00 heroku[slugc]: Slug compilation started
2013-01-24T01:43:51+00:00 heroku[slugc]: Slug compilation failed: failed to compile Python app
2013-01-24T02:27:36+00:00 heroku[slugc]: Slug compilation started
2013-01-24T02:28:08+00:00 heroku[slugc]: Slug compilation failed: failed to compile Python app
2013-01-24T02:32:08+00:00 heroku[slugc]: Slug compilation started
2013-01-24T02:32:32+00:00 heroku[slugc]: Slug compilation failed: failed to compile Python app
2013-01-24T02:43:32+00:00 heroku[slugc]: Slug compilation started
2013-01-24T02:43:59+00:00 heroku[slugc]: Slug compilation failed: failed to compile Python app
2013-01-24T02:46:23+00:00 heroku[slugc]: Slug compilation started
2013-01-24T02:46:52+00:00 heroku[slugc]: Slug compilation failed: failed to compile Python app
2013-01-24T02:49:48+00:00 heroku[slugc]: Slug compilation started
2013-01-24T02:50:26+00:00 heroku[slugc]: Slug compilation failed: failed to compile Python app
3 个回答
0
在Heroku部署的时候,你不需要在requirements.txt文件里写virtualenv==1.8.4.post1,请把它删掉,并把procfile和requirements文件放在git的根目录下。
1
这个错误信息说明找不到 virtualenv==1.8.4.post1
这个版本。当我在本地尝试这个命令时,也出现了同样的错误。看起来在 pypi 上没有这个版本。你可以试着把你的 requirements.txt 文件里的内容改成 virtualenv==1.8.4
吗?
3
我通过以下步骤成功运行了这个:
- 克隆你的git仓库
- 从你的
requirements.txt
文件中删除virtualenv==1.8.4
- 执行
git add .
- 执行
git commit -m "移除virtualenv依赖"
- 执行
git push heroku master
我猜想你在从依赖中移除virtualenv后,没有执行git add .
和git commit
。在你本地做的任何更改,只有在你执行add
和commit
之后,才会对github
和heroku
生效,最后还需要将这些更改push
到远程仓库,也就是Github或Heroku。