Push rejected failed to compile python app - django

so i get this error when i try to deploy my master branch, i have set my requirements.txt, runtime.txt and Procfile but i still get this error
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/python
-----> Python app detected
-----> Using Python version specified in runtime.txt
! Requested runtime (python - 3.9.7) is not available for this stack (heroku-20).
! Aborting. More info: https://devcenter.heroku.com/articles/python-support
! Push rejected, failed to compile Python app.
! Push failed
my requirements.txt file
asgiref==3.4.1
dj-database-url==0.5.0
Django==3.2.7
django-heroku==0.3.1
gunicorn==20.1.0
Pillow==8.4.0
psycopg2==2.9.2
python-decouple==3.5
pytz==2021.3
sqlparse==0.4.2
whitenoise==5.3.0
please help

Your python version is not supported on heroku stack 20 as stated in the fifth line to check supported runtime see Heroku documentation

Heroku stack supports python-3.9.9 so specify that in your runtime.txt:
python-3.9.9
Have a look at the stack at https://devcenter.heroku.com/articles/heroku-20-stack

Related

App not compatible with buildpack: Django + Python

When I click deployed button on heroku, I get some error, I have deployed this project for a certain period of time, and this time I deployed this error:
-----> Building on the Heroku-18 stack
-----> Using buildpack: heroku/python
-----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
! Push failed
I already have requirnments.txt, runtime.txt, Procfile, I already added buildpack(heroku/python) in setting,
requirnments.txt
asgiref==3.2.10
beautifulsoup4==4.9.3
dj-database-url==0.5.0
dj-static==0.0.6
Django==3.1.1
gunicorn==20.0.4
Pillow==8.1.2
psycopg2-binary==2.8.6
pytz==2020.1
soupsieve==2.2.1
sqlparse==0.3.1
static3==0.7.0
runtime.txt
python-3.7.3
Procfile
web: gunicorn APP_NAME.wsgi --log-file -
Any help or explanation is welcome! Thank you.
Did you push the source code from your master or main branch?
I was having the same problem as you when I pumped into this: Deploy from local branch.
So if you are not in main branch, you can either switch to one, or use git push heroku your-current-branch:master.\

Why do I have errors deploying to heroku?

I am trying to push my app to heroku, I am following the tutorial from udemy - everything goes smooth as explained. Once I am at the last step - doing git push heroku master I get the following error in the console:
(flaskdeploy) C:\Users\dmitr\Desktop\jose\FLASK_heroku>git push heroku master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to mitya-test-app.
remote:
To https://git.heroku.com/mitya-test-app.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mitya-test-app.git'
On a heroku site in the log area I have the following explanation of this error:
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Python app detected
-----> Installing python-3.6.13
-----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
-----> Installing SQLite3
-----> Installing requirements with pip
Collecting certifi==2020.12.5
Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Processing /home/linux1/recipes/ci/click_1610990599742/work
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/linux1/recipes/ci/click_1610990599742/work'
! Push rejected, failed to compile Python app.
! Push failed
In my requirements.txt I have the following:
certifi==2020.12.5
click # file:///home/linux1/recipes/ci/click_1610990599742/work
Flask # file:///home/ktietz/src/ci/flask_1611932660458/work
gunicorn==20.0.4
itsdangerous # file:///home/ktietz/src/ci/itsdangerous_1611932585308/work
Jinja2 # file:///tmp/build/80754af9/jinja2_1612213139570/work
MarkupSafe # file:///C:/ci/markupsafe_1607027406824/work
Werkzeug # file:///home/ktietz/src/ci/werkzeug_1611932622770/work
wincertstore==0.2
This is, in fact, only a super simple test app that consists of app.py:
from flask import Flask
app = Flask(__name__)
#app.route('/')
def index():
return "THE SITE IS OK"
if __name__ == '__main__':
app.run()
and Procfile with this inside:
web: gunicorn app:app
I see a windows path in your requirements.txt. Not sure what you are trying to do there, but is there any reason that you install the packages from a local source?
So, I believe looking at the log from
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/linux1/recipes/ci/click_1610990599742/work
means that pip tries to install from a directory that does not exist. Your heroku dyno (container) tries to get the necessary dependency but failed when building. If you are not familiar with container, in essence it's an isolated barebone system that will build from the ground up, so it needs to install them (click, flask, etc.)
tl;dr heroku wants install from local, failed. Try changing requirements.txt e.g.
certifi==2020.12.5
click
Flask
gunicorn==20.0.4
itsdangerous
Jinja2
MarkupSafe
Werkzeug
wincertstore==0.2
to force pip to install from outside source (i.e. pypi).
i think the problem is in requirement.txt
remove
click # file:///home/linux1/recipes/ci/click_1610990599742/work
Flask # file:///home/ktietz/src/ci/flask_1611932660458/work
itsdangerous # file:///home/ktietz/src/ci/itsdangerous_1611932585308/work
Jinja2 # file:///tmp/build/80754af9/jinja2_1612213139570/work
MarkupSafe # file:///C:/ci/markupsafe_1607027406824/work
Werkzeug # file:///home/ktietz/src/ci/werkzeug_1611932622770/work
and replace with
Flask==1.1.2
because the packages is not find by heroku. heroku will pull packages from requiremts.txt from pypi

During deploying Django blog on heroku showes me errors

When I deploy app in heroku show me this error
remote: ERROR: Could not find a version that satisfies the requirement apturl==0.5.2 (from -r /tmp/build_16067d5dbf345d8d906970e4d4f44d30/requirements.txt
I searched on internet to finding the solution of that problem but can't successfully find this.
So I show you what steps I had do for deploy app in heroku
I typed in terminal
heroku login
pip3 freeze
pip3 freeze > requirements.txt
Then for instaling gunicorn type in terminal
pip3 install gunicorn
Then make a file in root directory write name is Procifle in which I write
web: gunicorn django_project.wsgi
Then my heroku blog name
heroku git:remote -a naqviblog
I also show you my requirements.txt file
apturl==0.5.2
asgiref==3.2.3
asn1crypto==0.24.0
blinker==1.4
boto3==1.9.96
botocore==1.12.96
Brlapi==0.6.7
certifi==2018.8.24
chardet==3.0.4
command-not-found==0.3
cryptography==2.3
cupshelpers==1.0
defer==1.0.6
distro==1.3.0
distro-info===0.21ubuntu2
dj-database-url==0.5.0
Django==3.0.4
django-crispy-forms==1.9.0
django-heroku==0.3.1
django-storages==1.7.1
docutils==0.14
entrypoints==0.3
f.lux-indicator-applet==1.1.11rc0
galternatives==1.0.3
gunicorn==20.0.4
httplib2==0.11.3
idna==2.6
jmespath==0.9.3
keyring==17.1.1
keyrings.alt==3.1.1
language-selector==0.1
launchpadlib==1.10.6
lazr.restfulclient==0.14.2
lazr.uri==1.0.3
lightdm-gtk-greeter-settings==1.2.2
louis==3.8.0
macaroonbakery==1.2.1
Mako==1.0.7
MarkupSafe==1.1.0
netifaces==0.10.4
oauth==1.0.1
oauthlib==2.1.0
olefile==0.46
pbr==5.4.4
pexpect==4.6.0
Pillow==5.4.1
protobuf==3.6.1
psycopg2==2.7.7
pycairo==1.16.2
pycrypto==2.6.1
pycups==1.9.73
PyGObject==3.32.0
PyJWT==1.7.0
pymacaroons==0.13.0
PyNaCl==1.3.0
pyOpenSSL==19.0.0
pyRFC3339==1.1
python-apt===1.8.5-ubuntu0.3
python-dateutil==2.7.3
python-debian==0.1.34
python-decouple==3.3
pytz==2018.9
pyxattr==0.6.1
pyxdg==0.25
PyYAML==3.13
reportlab==3.5.18
requests==2.21.0
requests-unixsocket==0.1.5
s3transfer==0.2.0
SecretStorage==2.3.1
simplejson==3.16.0
six==1.12.0
sqlparse==0.3.1
system-service==0.3
systemd-python==234
testresources==2.0.1
ubuntu-advantage-tools==19.2
ubuntu-drivers-common==0.0.0
ufw==0.36
unattended-upgrades==0.1
urllib3==1.24.1
usb-creator==0.3.3
virtualenv==15.1.0
wadllib==1.3.3
whitenoise==4.1.2
xkit==0.0.0
youtube-dl==2019.1.17
zope.interface==4.3.2
Then type in terminal
git add .
git commit -m "commit changes"
finally type
git push heroku master
then showed me this error
Enumerating objects: 77, done.
Counting objects: 100% (77/77), done.
Delta compression using up to 4 threads
Compressing objects: 100% (60/60), done.
Writing objects: 100% (67/67), 3.72 MiB | 421.00 KiB/s, done.
Total 67 (delta 21), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Clearing cached dependencies
remote: -----> Installing python-3.6.10
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: Sqlite3 successfully installed.
remote: -----> Installing requirements with pip
remote: ERROR: Could not find a version that satisfies the requirement apturl==0.5.2 (from -r /tmp/build_d533b9574fcab74e6906cdc8732269b2/requirements.txt (line 1)) (from versions: none)
remote: ERROR: No matching distribution found for apturl==0.5.2 (from -r /tmp/build_d533b9574fcab74e6906cdc8732269b2/requirements.txt (line 1))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to naqviblog.
remote:
To https://git.heroku.com/naqviblog.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/naqviblog.git'
when open this link https://git.heroku.com/naqviblog.git
then show me on browser
Method Not Allowed
That's a lot of packages. Are you sure your project requires them all?
You added the python-3.7 tag but Heroku says it is using python 3.6. Ensure that both developing and production environment match.
apturl does not exist on PyPI https://pypi.org/. When you run python -m pip install packagename you search for it on PyPI. It does not exist on there. You may have installed it through apt, setup.py, wheels, etc.

Fail to push to Heroku: /app/.heroku/python/bin/pip:No such file or directory

I am trying to push a Django project to Heroku, but it keeps telling me that the following:
/app/.heroku/python/bin/pip: No such file or directory
The complete error message is shown below. How can I address this issue? Do I need to first install pip on Heroku?
Counting objects: 451, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (383/383), done.
Writing objects: 100% (451/451), 1.07 MiB | 349.00 KiB/s, done.
Total 451 (delta 87), 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/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51
/bin/steps/pip-install: line 5: /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 rocky-tor-70537.
remote:
To https://git.heroku.com/rocky-tor-70537.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/rocky-tor-70537.git'
My requirements.txt file is empty, as shown below.
# this is for Heroku and other servers.
# Locally, you should install requirements_base.txt
-r requirements_server.txt
My requirements_server.txt is as follows:
-r requirements_base.txt
# packages that are unnecessary on Windows/Mac local dev environments, or don't install properly
psycopg2>=2.5.1
My requirements_base.txt is as follows:
appdirs==1.4.3
asgi-redis==0.14.1
asgiref==0.14.0
autobahn==0.16.0
Babel==2.3.4
boto==2.42.0
channels==0.17.3
colorama==0.3.7
contextlib2==0.5.4
coverage==4.2
daphne==0.14.3
dj-database-url==0.4.1
Django==1.8.8
django-countries==4.0
django-easymoney==0.7.1
django-floppyforms==1.7.0
django-idmap==0.4.1
django-vanilla-views==1.0.4
djangorestframework==3.4.6
honcho==0.7.1
huey==1.2.0
IPy==0.83
mock==2.0.0
msgpack-python==0.4.8
otree-core==1.2.8
otree-save-the-change==1.1.3
packaging==16.8
pbr==1.10.0
py==1.4.31
pyparsing==2.2.0
pytest==2.9.2
pytest-django==3.0.0
python-redis-lock==3.2.0
pytz==2016.6.1
raven==5.25.0
redis==2.10.5
requests==2.11.1
schema==0.6.2
six==1.10.0
Twisted==16.2.0
txaio==2.5.1
unicodecsv==0.14.1
whitenoise==3.2.1
ws4py==0.3.5
XlsxWriter==0.9.3
zope.interface==4.2.0
I ran into this issue recently and was able to adjust it by changing the python version in the runtime.txt.
Changing to
python-3.5.2
But based off your requirements that you have listed, it seems like you are never getting to the requirements_base.txt.
In your requirements_server.txt file, change it so that:
-r requirements_base.txt
is listed there.
I simply had two typos in my runtime.txt
Make sure it says python-3.6.1 and not Python-3.6.1 or python 3.6.1
The error message is pretty bad. May this post save someone 30 minutes.
Looks like Heroku now supports only 3.6.1 and 2.7.13 Python versions.
https://devcenter.heroku.com/articles/python-runtimes#supported-python-runtimes
If you are using the default heroku buildpack I would guess that the requirements.txt file in your project folder is missing.
I had the same problem on Ubuntu 16.04 and after manually installing Heroku CLI, using
wget https://cli-assets.heroku.com/branches/stable/heroku-REPLACE_ME_OS-REPLACE_ME_ARCH.tar.gz -O heroku.tar.gz
mkdir -p /usr/local/lib
tar -xvzf heroku.tar.gz -C /usr/local/lib
/usr/local/lib/heroku/install
it worked like a charm.
In the folder I have 4 files. One is python script, second is procfile (no extension) with content web: gunicorn skripta1:app. Third is requirements.txt with:
appdirs==1.4.3
bokeh==0.12.5
click==6.7
Flask==0.12.2
gunicorn==19.7.1
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
numpy==1.12.1
packaging==16.8
pandas==0.20.1
pandas-datareader==0.4.0
pyparsing==2.2.0
python-dateutil==2.6.0
pytz==2017.2
PyYAML==3.12
requests==2.14.2
requests-file==1.4.2
requests-ftp==0.3.1
six==1.10.0
tornado==4.5.1
Werkzeug==0.12.2
And fourth is runtime.txt with python-3.5.2
According to Heroku documentation, the only two officially supported python runtimes are 2.7.13, and 3.6.1.
I recently had the same issue with oTree deployment in heroku, but as soon as I changed runtime.txt to python-3.6.1 everything went smoothly.
Oh dear - I removed a blank line in my requirements/production.txt in order to try and change the line number and everything started working (or rather on to my next completely different error)
I ran into this same problem on Windows trying to deploy a Python app to Heroku. Turns out it was a file encoding problem. Depending on how you create Procfile, requirements.txt and runtime.txt your encoding may vary.
Assuming you're running Windows, use PowerShell. Get the following PowerShell Function and paste it in to your PowerShell console. Using this, you can check your file encoding:
get-fileencoding requirements.txt
If it comes back anything besides ascii that's probably the issue. In my case, my three files were all unicode. I just did this to force them to ASCII:
'python-3.6.1' | out-file -en ascii runtime.txt
You can also use an editor and then save the file using ASCII encoding.
Once I made this change to my Procfile, requirements.txt and runtime.txt I was able to successfully deploy to Heroku.
I was switching from app engine to heroku and had a setup.cfg file in the root directory with following content:
[install]
prefix=
It caused this issues while deployment. After removing everything went well.

Cant upload my application with Django in Heroku

I'm trying to upload my application in heroku but when i try to do the first push I get this:
-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.4.
-----> Preparing Python runtime (python-2.7.4)
-----> Installing Distribute (0.6.36)
-----> Installing Pip (1.3.1)
-----> Installing dependencies using Pip (1.3.1)
then, the proccess stop working for a long time and it neve finish. After 15 minutes I got hits:
! Timed out compiling Python app (15 minutes)
! See https://devcenter.heroku.com/articles/slug-compiler#time-limit
What can I do?
My requirements.txt is like that:
Django==1.5.2
argparse==1.2.1
distribute==0.6.24
wsgiref==0.1.2