OpenShift Site not loading after pushing - python

after going through the below instructions, I reload my page yet I'm still seeing the default page of Openshift instead of the page of my site.
Openshift instructions I followed
git clone ssh://517f4cdc5973cae128000169#newlocarte-locdada.rhcloud.com/~/git/newlocarte.git/
cd newlocarte/
This will create a folder with the source code of your application. After making a change, add, commit, and push your changes.
git add .
git commit -m 'My changes'
git push
In my Git command:
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 262 bytes, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: restart_on_add=false
remote: Done
remote: restart_on_add=false
remote: Running .openshift/action_hooks/pre_build
remote: New python executable in /var/lib/openshift/517f4cdc5973cae128000169//py
thon-2.7/virtenv/bin/python
remote: Installing setuptools..................done.
remote: Installing pip...............done.
remote: Running virtualenv with interpreter /var/lib/openshift/517f4cdc5973cae12
8000169//python-2.7/opt/bin/python
remote: - Created/Updated virtenv and activated it.
remote: - Found setup.py. Processing it ...
remote: running develop
remote: running egg_info
remote: creating YourAppName.egg-info
remote: writing requirements to YourAppName.egg-info/requires.txt
remote: writing YourAppName.egg-info/PKG-INFO
remote: writing top-level names to YourAppName.egg-info/top_level.txt
remote: writing dependency_links to YourAppName.egg-info/dependency_links.txt
remote: writing manifest file 'YourAppName.egg-info/SOURCES.txt'
remote: reading manifest file 'YourAppName.egg-info/SOURCES.txt'
remote: writing manifest file 'YourAppName.egg-info/SOURCES.txt'
remote: running build_ext
remote: Creating /var/lib/openshift/517f4cdc5973cae128000169/python-2.7/virtenv/
lib/python2.7/site-packages/YourAppName.egg-link (link to .)
remote: YourAppName 1.0 is already the active version in easy-install.pth
remote:
remote: Installed /var/lib/openshift/517f4cdc5973cae128000169/app-root/runtime/r
epo
remote: Processing dependencies for YourAppName==1.0
remote: Searching for gevent==0.13.8
remote: Best match: gevent 0.13.8
remote: Processing gevent-0.13.8-py2.7-linux-x86_64.egg
remote: gevent 0.13.8 is already the active version in easy-install.pth
remote:
remote: Using /var/lib/openshift/517f4cdc5973cae128000169/python-2.7/virtenv/lib
/python2.7/site-packages/gevent-0.13.8-py2.7-linux-x86_64.egg
remote: Searching for greenlet==0.4.0
remote: Best match: greenlet 0.4.0
remote: Processing greenlet-0.4.0-py2.7-linux-x86_64.egg
remote: greenlet 0.4.0 is already the active version in easy-install.pth
remote:
remote: Using /var/lib/openshift/517f4cdc5973cae128000169/python-2.7/virtenv/lib
/python2.7/site-packages/greenlet-0.4.0-py2.7-linux-x86_64.egg
remote: Finished processing dependencies for YourAppName==1.0
remote: - Done processing setup.py
remote: Making script /var/lib/openshift/517f4cdc5973cae128000169//python-2.7/vi
rtenv/bin/pip relative
remote: Script /var/lib/openshift/517f4cdc5973cae128000169//python-2.7/virtenv/b
in/activate.csh cannot be made relative (it's not a normal script that starts wi
th #!/var/lib/openshift/517f4cdc5973cae128000169/python-2.7/virtenv/bin/python)
remote: Making script /var/lib/openshift/517f4cdc5973cae128000169//python-2.7/vi
rtenv/bin/pip-2.7 relative
remote: Making script /var/lib/openshift/517f4cdc5973cae128000169//python-2.7/vi
rtenv/bin/easy_install relative
remote: Script /var/lib/openshift/517f4cdc5973cae128000169//python-2.7/virtenv/b
in/activate.fish cannot be made relative (it's not a normal script that starts w
ith #!/var/lib/openshift/517f4cdc5973cae128000169/python-2.7/virtenv/bin/python)
remote: Making script /var/lib/openshift/517f4cdc5973cae128000169//python-2.7/vi
rtenv/bin/easy_install-2.7 relative
remote: Running .openshift/action_hooks/build
remote: New python executable in /var/lib/openshift/517f4cdc5973cae128000169//py
thon-2.7/virtenv/bin/python
remote: Installing setuptools..................done.
remote: Installing pip...............done.
remote: Running virtualenv with interpreter /var/lib/openshift/517f4cdc5973cae12
8000169//python-2.7/opt/bin/python
remote: Running .openshift/action_hooks/deploy
remote: hot_deploy_added=false
remote: MySQL already running
remote: Done
remote: Running .openshift/action_hooks/post_deploy
To ssh://517f4cdc5973cae128000169#newlocarte-locdada.rhcloud.com/~/git/ newlocarte.git/
cd033bf..95121b4 master -> master
Skizzy#H43K /c/Python27/Scripts/env/Scripts/art/newlocarte (master)
How can I make it load?

Please ssh into the app gear and make sure your code got pushed onto the gear. To ssh into the gear, run the command "rhc ssh -a {appName}". Also make sure your application related files are under wsgi directory.

try this
rhc app-restart <app> [--namespace NAME] [--app NAME]

Related

ERROR:Deploying Python app using heroku CLI

When I enter
$ git push heroku master
It Shows:
ERROR: Double requirement given: telegram (from -r /tmp/build_996aa7e0/requirements.txt (line 60)) (already in telegram==0.0.1 (from -r /tmp/build_996aa7e0/requirements.txt (line 47)), name='telegram')
There is the All logs:
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (8/8), 7.00 KiB | 716.00 KiB/s, done.
Total 8 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> Python app detected
remote: -----> Installing python-3.6.13
remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: ERROR: Double requirement given: telegram (from -r /tmp/build_996aa7e0/requirements.txt (line 60)) (already in telegram==0.0.1 (from -r /tmp/build_996aa7e0/requirements.txt (line 47)), name='telegram')
remote: ! Push rejected, failed to compile Python app.
remote: ! Push failed
remote: ! ## Warning - The same version of this code has already been built: 084ac888b168cf47da1ece8fd2b17b05e1d4df48
remote: ! We have detected that you have triggered a build from source code with version 084ac888b168cf47da1ece8fd2b17b05e1d4df48
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: ! If you are developing on a branch and deploying via git you must run:
remote: ! git push heroku :main
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote: Verifying deploy...
remote: ! Push rejected to zsk766.
remote: To https://git.heroku.com/zsk766.git
It looks like you've got telegram twice in your requirements.txt, once at line 60 and once at line 47.
Open requirements.txt, delete one of those lines, and repush your files.

Updating specific files with git for django app on heroku

I deployed my django app to heroku and its working well. When I change something in project on local files and want to push to heroku It always push all files and it takes time.
> git add templates/post/detail.html
> git commit -am "read more"
[master 153e38f] read more
2 files changed, 3 insertions(+), 3 deletions(-)
> git push heroku master
I use these commands. But it's deploying everything:
Enumerating objects: 13, done.
Counting objects: 100% (13/13), done.
Delta compression using up to 8 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 695 bytes | 695.00 KiB/s, done.
Total 7 (delta 5), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: ! Python has released a security update! Please consider upgrading to python-3.8.6
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> No change in requirements detected, installing from cache
remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: -----> $ python manage.py collectstatic --noinput
remote: 1392 static files copied to '/tmp/build_57ea00eb/staticfiles', 3734 post-processed.
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 280.5M
remote: -----> Launching...
remote: Released v15
remote: https://xxxxxxxxxx.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/xxxxxxxxxxxxxx.git
2d9ba8e..153e38f master -> master
The file that I changed around 1mb but it pushes 280mb. So what's the problem with it?
If you don't want to push your static file for every time then run this command :
heroku config:set DISABLE_COLLECTSTATIC=1
Enable static file for future:
heroku config:unset DISABLE_COLLECTSTATIC(for future use).

Push rejected, failed to compile Python app - Python version error

I have used Heroku with PHP in the past but this is the first time I am using Heroku with Python and Flask. For start, I want to create a simple "Hello World" app and then upload a more complex program I have built. Therefore the project's folder contains the following:
One "Hello World" Python script (called Main.py):
from flask import Flask, render_template
app = Flask(__name__)
#app.route("/")
def index():
return render_template("index.html", message="Hello World")
if __name__ == "__main__":
app.run(debug=True)
A templates file with a index.html file (see above) inside it
One runtime.txt file:
python-3.6.5
One requirements.txt file:
Flask==1.0.1
(The project is originally located at /Users/User/PycharmProjects/Project_HelloWorld.)
However, when I enter git push heroku master at the terminal then I am getting the following error:
Counting objects: 85, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (82/82), done.
Writing objects: 100% (85/85), 5.01 MiB | 3.13 MiB/s, done.
Total 85 (delta 24), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: ! The latest version of Python 3 is python-3.6.5 (you are using {\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
remote: {\fonttbl\f0\fmodern\fcharset0 Courier;}
remote: {\colortbl;\red255\green255\blue255;\red43\green47\blue49;\red237\green237\blue244;}
remote: {\*\expandedcolortbl;;\cssrgb\c21961\c24314\c25098;\cssrgb\c94510\c94510\c96471;}
remote: \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
remote: \deftab720
remote: \pard\pardeftab720\partightenfactor0
remote:
remote: \f0\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
remote: python-3.6.5}, which is unsupported).
remote: ! We recommend upgrading by specifying the latest version (python-3.6.5).
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing {\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
remote: {\fonttbl\f0\fmodern\fcharset0 Courier;}
remote: {\colortbl;\red255\green255\blue255;\red43\green47\blue49;\red237\green237\blue244;}
remote: {\*\expandedcolortbl;;\cssrgb\c21961\c24314\c25098;\cssrgb\c94510\c94510\c96471;}
remote: \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
remote: \deftab720
remote: \pard\pardeftab720\partightenfactor0
remote:
remote: \f0\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
remote: python-3.6.5}
remote: ! Requested runtime ({\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
remote: {\fonttbl\f0\fmodern\fcharset0 Courier;}
remote: {\colortbl;\red255\green255\blue255;\red43\green47\blue49;\red237\green237\blue244;}
remote: {\*\expandedcolortbl;;\cssrgb\c21961\c24314\c25098;\cssrgb\c94510\c94510\c96471;}
remote: \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
remote: \deftab720
remote: \pard\pardeftab720\partightenfactor0
remote:
remote: \f0\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
remote: python-3.6.5}) is not available for this stack (heroku-16).
remote: ! Aborting. More info: https://devcenter.heroku.com/articles/python-support
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to evening-sierra-26101.
remote:
To https://git.heroku.com/evening-sierra-26101.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/evening-sierra-26101.git'
How can I fix this error and properly run my app on Heroku?
Also when I am entering cat runtime.txt at the terminal for the runtime.txt above then I am getting the following (quite unexpected?) output:
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
{\fonttbl\f0\fmodern\fcharset0 Courier;}
{\colortbl;\red255\green255\blue255;\red43\green47\blue49;\red237\green237\blue244;}
{\*\expandedcolortbl;;\cssrgb\c21961\c24314\c25098;\cssrgb\c94510\c94510\c96471;}
\paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\deftab720
\pard\pardeftab720\partightenfactor0
\f0\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
python-3.6.5}%
I have firstly tried it with python-3.6.4 (instead of python-3.6.5) in the runtime.txt but I was getting the same error.
First I'd figure out how to run your app with gunicorn, as that's the most common deployment server for Flask apps. To run your app with gunicorn, you should be able to pip install gunicorn, then run from the root of your project: gunicorn my_file_name:app, where my_file_name == the name of the file that contains your Flask code above. E.g. if your Flask code is in a file named app.py, you'd run gunicorn app:app.
Once you can run the app with gunicorn, create a Procfile that specifies you want Heroku to run the server with gunicorn. Here's the contents of Procfile, which should be in the root of your project files (the same directory with requirements.txt):
web: gunicorn app:app
Then I'd update requirements.txt. Do a pip freeze | grep gunicorn to get your gunicorn version then add it to the requirements.txt file:
Flask==1.0.1
gunicorn==19.7.1
Finally, to resolve the immediate cause of your error above, I'd set runtime.txt to:
python-3.6.4
Then git push heroku master should be able to get you going...
If all else fails, here's a simple repository that has a barebones Flask app with Heroku deployment instructions in the README. It's deployed here: https://myapp-name-1.herokuapp.com/
So I found what it was going wrong and now my "Hello World" can run properly on Heroku.
The problem was the that even though I created anew the runtime.txt file and the requirements.txt for some reason the following "text" was inserted in them before the proper text:
\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
remote: {\fonttbl\f0\fmodern\fcharset0 Courier;}
remote: {\colortbl;\red255\green255\blue255;\red43\green47\blue49;\red237\green237\blue244;}
remote: {\*\expandedcolortbl;;\cssrgb\c21961\c24314\c25098;\cssrgb\c94510\c94510\c96471;}
remote: \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
remote: \deftab720
remote: \pard\pardeftab720\partightenfactor0
remote:
remote: \f0\fs26 \cf2 \cb3 \expnd0\expndtw0\kerning0
This was displayed at the error that I posted above when I was trying to do git push heroku master at my app and when I was entering cat runtime.txt. I finally spotted this by using a Hex editor. Therefore, Heroku was not only reading python-3.6.4 in my runtime.txt but also all this thing that I posted above before actually reading python-3.6.4. and this is the reason why I was getting an error.
As #Chris notes below at the comments, this unnecessary "text' was added (for some reason) because my .txt files were firstly saved (for some reason) as .txt.rtf and then I manually changed the extension to .txt without having in mind that something more was saved in them even thought I changed the extension. I deleted all this unnecessary "text" with my Hex editor and now everything is working fine.

Django error deploying to heroku requirements

I am trying to deploy my a django app to heroku. I have a virtual environment(of course). I have the procfile, setup.py and runtime.txt set up correctly. It runs perfectly on a local development server, but when I push to heroku it gives some kind of error with the requirements file.
This is the third traceback after pushing to heroku. I changed the procfile the first two times and then it only gave errors with the procfile. Now that the procfile errors are gone I have some kind of error with this.
Traceback:
Counting objects: 3, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 309 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Using set buildpack heroku/python
remote: -----> Python app detected
remote: -----> Uninstalling stale dependencies
remote: Invalid requirement: 'There was a problem loading the given requirements files.'
remote: Traceback (most recent call last):
remote: File "/app/.heroku/python/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/req/req_install.py", line 77, in
__init__
remote: req = pkg_resources.Requirement.parse(req)
remote: File "/app/.heroku/python/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/_vendor/pkg_resources/__init__.p
y", line 3036, in parse
remote: req, = parse_requirements(s)
remote: File "/app/.heroku/python/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/_vendor/pkg_resources/__init__.p
y", line 2980, in parse_requirements
remote: "version spec")
remote: File "/app/.heroku/python/lib/python3.5/site-packages/pip-8.1.1-py3.5.egg/pip/_vendor/pkg_resources/__init__.p
y", line 2945, in scan_list
remote: raise RequirementParseError(msg, line, "at", line[p:])
remote: pip._vendor.pkg_resources.RequirementParseError: Expected version spec in There was a problem loading the given
requirements files. at was a problem loading the given requirements files.
remote:
remote: You are using pip version 8.1.1, however version 8.1.2 is available.
remote: You should consider upgrading via the 'pip install --upgrade pip' command.
remote: $ pip install -r requirements.txt
remote:
remote:
remote: -----> Discovering process types
remote: Procfile declares types -> web, worker
remote:
remote: -----> Compressing...
remote: Done: 60.3M
remote: -----> Launching...
remote: Released v6
remote: https://calm-caverns-85777.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/calm-caverns-85777.git
b1b06b0..d6b1a95 master -> master
Procfile:
web: gunicorn blog.wsgi
worker: python worker.py
requirements.txt:
dj-database-url==0.4.1
Django==1.9.7
django-crispy-forms==1.6.0
django-markdown-deux==1.0.5
django-pagedown==0.1.1
gunicorn==19.6.0
markdown2==2.3.1
Pillow==3.2.0
whitenoise==3.2
runtime.txt:
python-3.5.1
I can install the dependancies locally from the requirements.txt file and the other thing is when I try to update pip it says it is already up to date. My runtime environment is set to python 3.5.1. The app crashes when it is deployed and I am assuming it is because of the traceback errors. What can I do to fix this?
How was the requirements.txt file created? Is it possible it is corrupted or not plain text or has non-printable characters in it?
I recommend deleting requirements.txt and generating it cleanly based on pip freeze.
If you are using Windows Powershell the encoding issue could be affecting you. The suggested solution is:
pip freeze | Out-File -Encoding ASCII requirements.txt

How can I tail logs from OpenShift to be verbose about python setup.py, virtualenv, and pip?

When I run:
rhc tail -a myapp
I do see a stream of log messages at app startup, but nothing about the setup of the virtualenv and installation of dependencies in requirements.txt, like flask etc. How can I better monitor this on the server for the purposes of debugging, in case I run into a problem? This is fairly easy to do in Heroku, but I'm considering migrating apps to OpenShift, but only if options for debugging python are very flexible.
When you git push changes to your app you OpenShift responds with detailed output regarding the status of setup.py, requirements.txt, etc. Here is sample (abbreviated) output from a deployment to a Python app on OpenShift:
$ git commit -m "Adds BeautifulSoup"
$ git push
Counting objects: 3, done.
...
remote: Stopping Python 3.3 cartridge
remote: Waiting for stop to finish
...
remote: Building git ref 'master', commit 8d92954
remote: Activating virtenv
remote: Checking for pip dependency listed in requirements.txt file..
...
remote: Collecting beautifulsoup4 (from -r /var/lib/openshift/553fde444382eca8a0000028/app-root/runtime/repo/requirements.txt (line 1))
...
remote: Downloading http://mirror1.ops.rhcloud.com/mirror/python/web/packages/source/b/beautifulsoup4/beautifulsoup4-4.3.2.tar.gz (143kB)
remote: Installing collected packages: beautifulsoup4
remote: Running setup.py install for beautifulsoup4
remote: Successfully installed beautifulsoup4-4.3.2
remote: Running setup.py script..
remote: running develop
remote: running egg_info
remote: creating YourAppName.egg-info
remote: writing top-level names to YourAppName.egg-info/top_level.txt
remote: writing YourAppName.egg-info/PKG-INFO
remote: writing dependency_links to YourAppName.egg-info/dependency_links.txt
remote: writing manifest file 'YourAppName.egg-info/SOURCES.txt'
remote: running build_ext
remote: Creating /var/lib/openshift/553fde444382eca8a0000028/app-root/runtime/dependencies/python/virtenv/venv/lib/python3.3/site-packages/YourAppName.egg-link (link to .)
remote: Adding YourAppName 1.0 to easy-install.pth file
remote: Installed /var/lib/openshift/553fde444382eca8a0000028/app-root/runtime/repo
remote: Processing dependencies for YourAppName==1.0
remote: Finished processing dependencies for YourAppName==1.0
remote: Preparing build for deployment
remote: Deployment id is d9c707fb
remote: Activating deployment
remote: Starting Python 3.3 cartridge (Apache+mod_wsgi)
remote: Application directory "/" selected as DocumentRoot
remote: Application "wsgi.py" selected as default WSGI entry point
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
Best thing to do imo in this case is to ssh into your gear. Once logged in you can change into the app directory and view all log/config files directly.

Categories