Heroku Pymongo fails deployment at "Preparing static assets" - python

I am trying to deploy a Flask-Restful app which has the following dependencies:
Flask==0.10.1
Flask-RESTful==0.2.12
Jinja2==2.7.3
MarkupSafe==0.23
Werkzeug==0.9.6
aniso8601==0.85
argparse==1.2.1
gunicorn==19.1.1
itsdangerous==0.24
pymongo==2.7.2
pytz==2014.9
six==1.8.0
wsgiref==0.1.2
When I remove the pymongo package from the file and git push heroku master everything is ok and working.
When I add it again and try to deploy the process stuck at:
Successfully installed pymongo
Cleaning up...
-----> Preparing static assets
And then it hits timeout after 15 minutes. Any ideas why it stucks there and how can I escape it?
Thanks!

heroku config: set DISABLE_COLLECTSTATIC = 1
This for the moment fixed the problem so the upload is successful. I am still waiting for the Heroku's team support, they said they are working on the problem.

Related

CS50W lecture7 testing,CI/CD--a problem about YAML and GitHub Actions

I am taking CS50’s Web Programming with Python and JavaScript(CS50W) course. I am now having a problem for lecture 7 Testing, CI/CD. When I followed along Brian in the GitHub Actions section(Timestamp at about 1:13:36), the result in my GitHub Actions turned out not to be the same with his.
This is the yaml code( I exactly copied from the lecture) :
name: Testing
on: push
jobs:
test_project:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Run Django unit tests
run:
pip3 install --user django
python manage.py test
In his GitHub Actions there was nothing wrong about the "run django unit tests" part. But Mine turned out to have some errors. My result in GitHub Actions showed as this(Click to see the screenshot):
Run pip3 install --user django python manage.py test
pip3 install --user django python manage.py test
shell: /usr/bin/bash -e {0}
Collecting django
Downloading Django-4.0.3-py3-none-any.whl (8.0 MB)
ERROR: Could not find a version that satisfies the requirement python (from versions:
none)
ERROR: No matching distribution found for python
Error: Process completed with exit code 1.
So I thought there was something wrong for setting up django or python in the GitHub Ubuntu virtual machine, then I tried to get rid of the python manage.py test syntax in the yaml file, and the "run django unit tests" in GitHub Actions turned out no errors. The result showed as(Click to see the screenshot)
Run pip3 install --user django
pip3 install --user django
shell: /usr/bin/bash -e {0}
Collecting django
Downloading Django-4.0.3-py3-none-any.whl (8.0 MB)
Collecting asgiref<4,>=3.4.1
Downloading asgiref-3.5.0-py3-none-any.whl (22 kB)
Collecting backports.zoneinfo; python_version < "3.9"
Downloading backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl (74 kB)
Collecting sqlparse>=0.2.2
Downloading sqlparse-0.4.2-py3-none-any.whl (42 kB)
Installing collected packages: asgiref, backports.zoneinfo, sqlparse, django
Successfully installed asgiref-3.5.0 backports.zoneinfo-0.2.1 django-4.0.3 sqlparse-
0.4.2
It seems django was successfully installed. But what went wrong when the python manage.py test syntax was added in the yaml file? I completely have no idea. Can someone point it out? Thanks a lot! You might wanna have a look at my GitHub repository for this. If your need more infomation please just tell me. THANKS!!!
The error message you were getting indicates that it tried to install python in:
ERROR: No matching distribution found for python
but python refers to your second command, python manage.py test
So the error message indicates that it is trying to run two commands as one single command.
When running multiple commands, you have to include the | character, so Github Actions understands that there are multiple commands to be run. In the lecture you can see that Brian included the necessary | character:
run: |
pip3 install --user django
python manage.py test

Heroku python app failing to build when installing sqlite3

My Python app on Heroku failed to build consistently:
-----> Python app detected
! Python has released a security update! Please consider upgrading to python-3.6.8
Learn More: https://devcenter.heroku.com/articles/python-runtimes
-----> Found python-3.6.4, removing
-----> Installing python-3.6.7
-----> Installing pip
-----> Installing SQLite3
! Push rejected, failed to compile Python app.
! Push failed
It is a Django application that runs fine locally.
python-3.6.7 specified in runtime.txt, and I've tried other versions.
My Procfile contains:
release: python <appname>/manage.py migrate
web: python <appname>/manage.py runserver 0.0.0.0:$PORT
I could probably use gunicorn but that's irrelevant here. The build logs doesn't seem to provide me any information.
requirements.txt
chardet==3.0.4
Django==2.0.2
idna==2.6
pytz==2018.3
requests==2.18.4
urllib3==1.22
dj-database-url==0.5.0
setuptools==1.0.0
Try this in your app.json. Although it a temporary solution
"buildpacks": [
{
"url": "https://github.com/heroku/heroku-buildpack-python.git#remove-
sqlite"
},
See: https://travis-ci.org/heroku/heroku-buildpack-python
Upgrade the the stack from heroku-16 to heroku-18 in app.json.

Flask app not compatible with Buildpack Python heroku

I have Flask application that I want to apply to Heroku.
I have made a Procfile as such:
web: gunicorn routes:app
and a requirements.txt:
click==6.7
Flask==0.12
gunicorn==19.6.0
itsdangerous==0.24
Jinja2==2.8.1
MarkupSafe==1.0
Werkzeug==0.14.1
but whenever I try to run the command:
git push heroku master
I always get this error:`App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
even though I have set the buildpack to python. My main python file is called routes.py, so the Profile should be correct, and I have made a lot of research and all the dependencies seems to be there, what could be the issue?
for all my dependencies I also have a Pipfile and a Pipfile.lock..
I tried using pip install --upgrade -r requirements.txt
and this resulted in this error:
No matching distribution found for adium-theme-ubuntu==0.3.4 (from -r /tmp/build_622384b275f7a5f640333152a3b25ba1/requirements.txt (line 1))
output of Git Status:
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
Errors i get from my requirements.txt
File "/app/.heroku/python/lib/python3.6/site-packages/setuptools/__init__.py", line 5, in <module>
import distutils.core
File "/app/.heroku/python/lib/python3.6/distutils/core.py", line 16, in <module>
from distutils.dist import Distribution
File "/app/.heroku/python/lib/python3.6/distutils/dist.py", line 9, in <module>
import re
File "/app/.heroku/python/lib/python3.6/re.py", line 142, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-oqscorl3/enum34/
Push rejected, failed to compile Python app.
When I recently received similar errors, I was able to drop the version numbers from my requirements.txt to get a successful deploy.
For anyone still seeking an answer, it appears the requirements.txt is missing dependency adium-theme-ubuntu==0.3.4 as stated in the error message. The package doesn't exist on PyPI, so pip install won't work. That's why the deployment failed.
In this case, it's often helpful to run pip freeze again to see if any new dependency caused error.
If nothing helps, better do a clean reinstall of everything:
rm -rf venv
python -m venv venv
pip install DEPENDENCY-NAME
Then try deploying again.

Heroku Python Webapp - pip is not found, and runtime is default despite runtime.txt

I am a novice and don't understand many of the concepts, so excuse me if there are some ambiguities or plain fallacies in my statements and questions.
I am writing a web app using Flask python framework. I have already tested it on localhost. Now I want to deploy it to heroku's webserver.
Here is the folder where the main files are stored:
static #this is a folder
templates #this is a folder
Procfile
requirements.txt
runtime.txt
app.py
Now here are the contents of Procfile, requirements.txt and runtime.txt respectively:
Procfile:
web: gunicorn app:app
requirements.txt:
Flask==0.12.2
gunicorn==19.7.1
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
Werkzeug==0.12.2
runtime.txt:
python-2.7.1
Now, it was python-3.5.1 in runtime.txt , before I had the problem but now during debugging I've left it as 2.7.1, because there's another problem I find.
Now when I try to execute the command: git push heroku master, the following ouptut is generated:
Counting objects: 13, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (13/13), 1.95 KiB | 0 bytes/s, done.
Total 13 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.5.1
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote:
/app/tmp/buildpacks/{somelonghash}/bin/steps/pip-
install: line 7: /app/.heroku/python/bin/pip: No such file or
directory
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to joecrownwebapp.
remote:
To https://git.heroku.com/joecrownwebapp.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to
'https://git.heroku.com/joecrownwebapp.git'
Where {somelonghash} was some long hash which for the purposes of this question I've removed. Now as you can see first the app is being deployed with python-3.5.1 which is strange given the fact that I've specified in runtime.txt that the runtime should be for example 2.7.1. Now we also see that pip is being installed and thereafter the requirements are being installed with pip and that is where the problem occurs.
The first question that comes to my mind is: Where exactly is this "/app/.heroku/python/bin/pip:" directory supposed to be, or for that matter "/app/tmp/buildpacks/{somelonghash}/bin/steps/pip-
install"?
Are they somewhere on my machine? (I figure not because if they are unix-based pathnames, then app should be directly under root, but I dont have such a folder)
If they are not on my machine where are they, how can I locate them and examine them. Are they somewhere on the Heroku server. If so, where does my problem arise from? Why is my runtime.txt disregarded?
Any ideas would be greatly appreciated!

Heroku Python failed to detect app matching buildpack

I can't deploy my Flask app to Heroku...
I've searched in every thread I can and nothing worked for me : add a runtime.txt, set a buildpack. I don't know what can be wrong now.
Here is my root directory for the app :
Project
- .git
- Procfile
- Readme.md
- app
- config.py
- requirements.txt
- runtime.txt
- web.py
Here's the content of requirements.txt:
appdirs==1.4.3
click==6.7
Flask==0.12.1
Flask-WTF==0.14.2
itsdangerous==0.24
Jinja2==2.9.5
MarkupSafe==1.0
packaging==16.8
pyparsing==2.2.0
six==1.10.0
Werkzeug==0.12.1
WTForms==2.1
The Procfile :
web: python web.py
And the runtime.txt:
python-2.7.13
When I do git push heroku master, it prints:
remote: Compressing source files... done.
remote: Building source:
remote:
remote: ! No default language could be detected for this app.
remote: HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
remote: See https://devcenter.heroku.com/articles/buildpacks
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to appname.
remote:
I tried to add a buildpack with heroku buildpacks:add heroku/Python but then it says that it can't detect app for python buildpack.
What could I possibly did wrong ?
Change requirements.py to requirements.txt.
If you're using the default Python 2.7.13 you shouldn't need a runtime.txt. You'd think that specifying the runtime would trigger the language detection but even without packages to install, Heroku requires an empty requirements.txt.
I was spend time with a very similar error.
In my case, i tried to deploy a django app.
I just run these commands to setup the buildpack
heroku login
heroku create --stack cedar --buildpack git://github.com/heroku/heroku-buildpack-python.git
heroku config:add BUILDPACK_URL=git#github.com:heroku/heroku-buildpack-python.git#purge
heroku config:set HEROKU=1
I decided to post this here because it took me a long time to get these tips
edit the content of your Procfile to
web: gunicorn web:app --log-file=-
I assume your web.py file is contained in your project's root folder i.e you see it once you enter your project's "Project" folder.
Otherwise, if it is contained in the app folder then use
web: gunicorn app.web:app --log-file=-
I also run into similar problem. I was able to fix it by adding the runtime.txt
just put the version of the python you are using in the runtime.txt
python-2.7.14
I'm late the to party but if you already have a requirements.txt file and you're getting this error, try adding a Procfile like shown here in the documentation:
https://devcenter.heroku.com/articles/getting-started-with-python#define-a-procfile

Categories

Resources