Python(Django) giving error while pushing on heroku - python

I am new to heroku as well as python (Django). i have made an app in django and want to push on heroku. but on git push heroku master it giving me this error.
Writing objects: 100% (245/245), 10.37 MiB | 110.00 KiB/s, done.
Total 245 (delta 35), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing Python-2.7.13
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote: /app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda
all: 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 djangoshopnror.
remote:
To https://git.heroku.com/djangoshopnror.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to
'https://git.heroku.com/djangoshopnror.git'
i have requirements.txt file and runtime.txt file.
runtime.txt look like this
Python-2.7.13
and requirements.txt look like this
BestBuyAPI==0.0.51
dj-database-url==0.4.2
Django==1.9
django-cors-headers==2.0.2
djangorestframework==3.6.2
djangorestframework-jwt==1.10.0
ebaysdk==2.1.4
gunicorn==19.7.1
lxml==3.7.3
psycopg2==2.7.1
PyJWT==1.5.0
pytz==2017.2
requests==2.7.0
virtualenv==15.1.0
wapy==1.0.0
whitenoise==3.3.0
one weired thing is when i change runtime.txt with python version 3.5.x it works. but due to some reasons i have to use python 2.7.x .
can anyone have answer about this. any suggestion or help will be highly appriciated.

Related

ERROR: Invalid requirement: 'asgiref 3.5.2'

I am new to heroku and I wanted to deploy a simple app, when i push to heroku it is given me the error below. I check online unfortunately I dont find the right answer to it.
ERROR GIVEN
Enumerating objects: 73, done.
Counting objects: 100% (73/73), done.
Delta compression using up to 4 threads
Compressing objects: 100% (71/71), done.
Writing objects: 100% (73/73), 24.58 KiB | 719.00 KiB/s, done.
Total 73 (delta 11), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Python app detected
remote: -----> No Python version was specified. Using the buildpack default: python-3.10.4
remote: To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.10.4
remote: -----> Installing pip 22.0.4, setuptools 60.10.0 and wheel 0.37.1
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: ERROR: Invalid requirement: 'asgiref 3.5.2' (from line 1 of /tmp/build_44a6c2b3/requirements.txt)
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to olakaymytodo.
remote:
To https://git.heroku.com/olakaymytodo.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/olakaymytodo.git'
I don't know waht have done wrong that make that show up my requirements.txt file is as follow
requirements.txt file
asgiref 3.5.2
Django 4.0.4
django-environ 0.8.1
environ 1.0
gunicorn 20.1.0
Pillow 9.1.1
pip 22.0.4
psycopg2 2.9.3
setuptools 62.1.0
sqlparse 0.4.2
tzdata 2022.1
wheel 0.37.1
is it the asgiref version?
I have search online but dont get a right answer to it. I hope someone here can help.
requirement.txt should be like this,
Try it,
asgiref==3.5.2
Django==4.0.4
django-environ==0.8.1
environ==1.0
gunicorn==20.1.0
Pillow==9.1.1
pip==22.0.4
psycopg2==2.9.3
setuptools==62.1.0
sqlparse==0.4.2
tzdata==2022.1
wheel==0.37.1

Running through an environmental error during deploying django app on heroku

I have created virtual env with anaconda prompt and created my django project in that env. I have created repository on github and push my code there and also create app on heroku but when i am running this git push heroku main command, it showing me an error which I have given below:
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/tmp/build/80754af9/asgiref_1605055780383/work'..
traceback:
PS C:\Users\AHMED\newrest\source> git push heroku main
Enumerating objects: 48, done.
Counting objects: 100% (48/48), done.
Delta compression using up to 4 threads
Compressing objects: 100% (44/44), done.
Writing objects: 100% (48/48), 16.22 KiB | 615.00 KiB/s, done.
Total 48 (delta 10), 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: -----> Installing python-3.8.5
remote: -----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: Processing /tmp/build/80754af9/asgiref_1605055780383/work
remote: ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/tmp/build/80754af9/asgiref_1605055780383/work'
remote:
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to restlearnsignup.
remote:
To https://git.heroku.com/restlearnsignup.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/restlearnsignup.git'
requirement file
asgiref # file:///tmp/build/80754af9/asgiref_1605055780383/work
astroid==2.4.1
certifi==2020.12.5
cffi==1.14.4
chardet==3.0.4
click==7.1.2
colorama==0.4.3
cryptography==3.3.1
decorator==4.4.2
Django==3.0.3
django-rest-knox==4.1.0
djangorestframework==3.12.2
dodgy==0.2.1
dynaconf==3.1.2
flake8==3.8.3
flake8-polyfill==1.0.2
gender-guesser==0.4.0
gunicorn==20.0.4
hvac==0.10.5
idna==2.10
isort==4.3.21
knox==0.1.11
lazy-object-proxy==1.4.3
loguru==0.5.3
mccabe==0.6.1
pep8-naming==0.10.0
prospector==1.3.0
pycodestyle==2.6.0
pycparser==2.20
pydocstyle==5.0.2
pyflakes==2.2.0
pylint==2.5.2
pylint-celery==0.3
pylint-django==2.0.15
pylint-flask==0.6
pylint-plugin-utils==0.6
pytz # file:///tmp/build/80754af9/pytz_1606604771399/work
PyYAML==5.3.1
requests==2.25.0
requirements-detector==0.7
setoptconf==0.2.0
shortuuid==1.0.1
six==1.15.0
snowballstemmer==2.0.0
sqlparse # file:///tmp/build/80754af9/sqlparse_1602184451250/work
toml==0.10.1
tqdm # file:///tmp/build/80754af9/tqdm_1607369919789/work
urllib3==1.26.2
validators==0.18.1
whitenoise==5.2.0
win32-setctime==1.0.3
wincertstore==0.2
wrapt==1.12.1
Anyone who know how to resolve this error ?. I learning deployment and I don't know much about this. I research but couldn't found anything helpful.
Use:
$ pip list
And edit the requirements.txt file to replace the temporary file with the actual version of the packages
Edit your requirements to point to asgiref version instead of temporary file
For example
asgiref==3.3.1

Error when push files to heroku (error: failed to push some refs to ...)

When I try to type "git push heroku master" in the console, I have the following problem. This is my second approach to heroku and again I have a problem in the same place, I was looking for advice on the Internet, but nothing helps me
(venv) C:\Users\patryk\Desktop\Django\MyPage>git push heroku master
Enumerating objects: 33, done.
Counting objects: 100% (33/33), done.
Delta compression using up to 4 threads
Compressing objects: 100% (27/27), done.
Writing objects: 100% (33/33), 17.14 KiB | 1.90 MiB/s, done.
Total 33 (delta 2), 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.7.3
remote: Learn More: https://devcenter.heroku.com/articles/python-
runtimes
remote: -----> Installing python-3.7.4
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to xxx.
remote:
To https://git.heroku.com/xxx.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/xxx.git'
requirements.txt file:
-r requirements-dev.txt
gunicorn
psycopg2
requirements-dev.txt file:
dj-database-url==0.5.0
dj-static==0.0.6
Django==2.2.4
django-bootstrap-form==3.4
djangorestframework==3.10.2
Pillow==6.1.0
python-decouple==3.1
pytz==2019.2
sqlparse==0.3.0
static3==0.7.0

Error when using $ git push heroku master even though runtime.txt is correct

I am trying to use $ git push heroku master but I get this error:
$ git push heroku master
Counting objects: 6, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 534 bytes | 534.00 KiB/s, done.
Total 6 (delta 0), 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 , 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
remote: ! Requested runtime () 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 securibot.
remote:
To https://git.heroku.com/securibot.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/securibot.git'
My runtime.txt file reads the following:
python-3.6.5
Any idea why I'm getting this error?
Did you read the referenced URL that was posted?
If you look through https://devcenter.heroku.com/articles/python-runtimes, you will see that "Newly created Python applications default to the Python 3.6.4 runtime".
You can specify your own run time in either your Pipfile or creating a runtime.txt with the following:
python-3.6.5

heroku push error python 3-6

I have an issue publishing my python code to heroku
keep in mind that this is my first project on heroku and first with anything to do with repositories
Counting objects: 18, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (16/16), done.
Writing objects: 100% (18/18), 21.80 KiB | 0 bytes/s, done.
Total 18 (delta 2), 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 python-3.6, 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 python-3.6
remote: ! Requested runtime (python-3.6) 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 project.
remote:
To https://git.heroku.com/project.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project.git'
Try this
pipenv lock
git add.
git commit -am "make it better"
git push heroku master
If you want a different version, edit the new file and enter the information in:
[requires]
python_version = "2.7" or [requires] python_full_version = "2.7.15"
your requirements.txt file must contain python-3.6.5 everything in small letters and - sign is important

Categories

Resources