2016-11-20 116 views
0

任何人都可以建議我什麼是錯的?heroku拒絕django應用程序推

Heroku總是拒絕代碼推送,因爲它無法構建我的代碼。從錯誤消息看來,當它試圖用pip安裝requirements.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' 

回答

0

請嘗試以下操作。

1.確保你已經安裝紅寶石,然後從你的終端運行以下命令:

wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh 

2.Login到Heroku的

$ heroku login 
Enter your Heroku credentials. 
Email: [email protected] 
Password (typing will be hidden): 
Authentication successful. 

3.創建您的應用程序,如果你有沒有創建

$ cd ~/myapp 
$ heroku create <app name> 

4.install git & git init在項目文件夾

5.login到Heroku的儀表盤讓你的應用程序的Git倉庫

6. git remote add heroku <repository url>

7.make項目的更改,並提交

8.create Procfile項目根文件夾

web:python manage.py runserver 
web: gunicorn <project-name>.wsgi --log-file - 
heroku ps:scale web=1 

9.創建項目根目錄中的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.Add在wsgi.py以下服務器的靜態文件

from whitenoise.django import DjangoWhiteNoise 
application = DjangoWhiteNoise(get_wsgi_application()) 

12.Commit更改和git push heroku master。 現在,打開你的瀏覽器並輸入https://your-app-name.heroku.com看魔術。

0

自己解決問題。解決方案出現錯誤消息「需求解析錯誤」。我發現新更新的require.txt文件中有一個語法錯誤。通過糾正這個問題,問題就消失了。

恥辱,似乎沒有辦法用戶可以直接看到什麼是完全錯誤的。希望我的共同故事能夠指導未來遇到同樣問題的編碼人員。

相關問題