[英]heroku rejected django app push
誰能建議我出了什么問題?
Heroku總是拒絕代碼推送,因為它無法構建我的代碼。 從錯誤消息看來,當嘗試使用pip安裝require.txt時,似乎未安裝Pip!
git push staging feature/homepage:master
Counting objects: 16, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (16/16), 1.48 KiB | 0 bytes/s, done.
Total 16 (delta 9), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: Usage: pip-diff [options]
remote:
remote: Traceback (most recent call last):
remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 116, in <module>
remote: main()
remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 112, in main
remote: diff(**kwargs)
remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 84, in diff
remote: r1 = Requirements(r1)
remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 29, in __init__
remote: self.load(reqfile)
remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 39, in load
remote: for requirement in parse_requirements(reqfile, finder=finder, session=requests):
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_file.py", line 93, in parse_requirements
remote: for req in req_iter:
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_file.py", line 192, in process_line
remote: for req in parser:
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_file.py", line 93, in parse_requirements
remote: for req in req_iter:
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_file.py", line 140, in process_line
remote: opts, _ = parser.parse_args(shlex.split(options_str), defaults)
remote: File "/app/.heroku/python/lib/python2.7/optparse.py", line 1402, in parse_args
remote: self.error(str(err))
remote: File "/app/.heroku/python/lib/python2.7/optparse.py", line 1584, in error
remote: self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg))
remote: File "/app/.heroku/python/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg/pip/req/req_file.py", line 284, in parser_exit
remote: raise RequirementsFileParseError(msg)
remote: pip.exceptions.RequirementsFileParseError: pip-diff: error: no such option: ------------------------
remote:
remote: $ pip install -r requirements.txt
remote: Usage: pip [options]
remote:
remote: pip: error: no such option: ------------------------
remote:
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to cryptic-forest-66390.
remote:
To https://git.heroku.com/cryptic-forest-66390.git
! [remote rejected] feature/homepage -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/cryptic-forest-66390.git'
嘗試以下方法。
1.確保已安裝Ruby,然后從終端運行此程序:
wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
2.登錄到Heroku
$ heroku login
Enter your Heroku credentials.
Email: adam@example.com
Password (typing will be hidden):
Authentication successful.
3.創建您的應用程序(如果尚未創建)
$ cd ~/myapp
$ heroku create <app name>
4.在您的項目文件夾中安裝git
& git init
5.登錄到Heroku儀表板獲取您的應用程序git存儲庫
6. git remote add heroku <repository url>
7,在項目中進行更改並提交
Procfile
在項目根文件夾中創建Procfile
web:python manage.py runserver
web: gunicorn <project-name>.wsgi --log-file -
heroku ps:scale web=1
9.Create requirements.txt
在項目的根文件夾中的文件
Django==1.9
gunicorn==19.4.5
psycopg2==2.6.1
whitenoise==2.0.6
wsgiref==0.1.2
dj-database-url==0.4.1
10.在您的settings.py
文件的末尾添加以下內容。
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
import dj_database_url
DATABASES['default'] = dj_database_url.config()
11.在wsgi.py中將以下內容wsgi.py
到服務器靜態文件中
from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(get_wsgi_application())
12.提交您的更改並git push heroku master
。 現在,打開瀏覽器,然后輸入https://your-app-name.heroku.com
了解魔術。
問題由我自己解決。 解決方案遵循錯誤消息“ requirement parse error”。 我發現新更新的require.txt文件中存在語法錯誤。 通過糾正這一點,問題就消失了。
令人遺憾的是,用戶似乎無法直接看到到底出了什么問題。 希望我分享的故事能幫助將來遇到同樣麻煩的編碼人員。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.