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
Related
So I try to make a very simple test app to run with Heroku. Its my 3rd attempt from complete scratch. I have a single python file with very minimal content
from flask import Flask
app = Flask(__name__)
#app.route("/")
def test():
return "test"
if __name__ == '__main__':
app.run()
the file is named test.py, my directory also includes Procfile
web: gunicorn app:test
and requirments.txt
click==7.1.2
Flask==1.1.2
gunicorn==20.1.0
itsdangerous==1.1.0
Jinja2==2.11.3
MarkupSafe==1.1.1
Werkzeug==1.0.1
to top it off I have gitignore to ensure IDE files do not interfere,
.idea
.Heroku.iml
and runtime.txt
python-3.6.0
I then try to create an app using
heroku create <appname>
I then use second URL it returns in the command
git remote add heroku <url>
. Afterwards I do
git add .
git commit -m "some message"
git push heroku main
and get the following error.
To https://git.heroku.com/forgotten-fox.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/forgotten-fox.git'
I then try to do it using
git push heroku master
instead but no changes occur.
I also try to force it to use python build pack with
heroku buildpack:set heroku/python --app <appname>
as above the error it states that
Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
I don't know how to use git mostly, but my friend advised me to create remote repository and attach it to Heroku but I was not able to find how to do the attachment.
If anyone knows what causes that and / or how to solve it i would really appreciate if you share the knowledge.
Update:
Thanks for pointing out wrong name for requirements file, I've renamed it. I`ve also changed my Procfile to
web: gunicorn test:app
.
Sadly it doesn't resolve the issue (yes I did commit and push the changes made).
Here is the error messages:
for git push heroku master :
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 6 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (11/11), 1.66 KiB | 1.66 MiB/s, done.
Total 11 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: 36fb38193ecf8aa8d27f79682de049be81cb8807
remote: !
remote: ! We have detected that you have triggered a build from source code with version 36fb38193ecf8aa8d27f79682de049be81cb8807
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
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 forgotten-fox.
remote:
To https://git.heroku.com/forgotten-fox.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/forgotten-fox.git'
and here for git heroku push main:
error: src refspec main does not match any
error: failed to push some refs to 'https://git.heroku.com/forgotten-fox.git'
.
Update
Ok, sorry everyone, I'm generally retarded. I missed the obvious part of error about build back, here it states the final fix I needed for my app to work.
the issue is that you have to use
web: gunicorn test:app
instead of
web: gunicorn app:test
the correct format is
gunicorn <filename>:<app object>
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.
There are a few posts with this particular issue however I've tried about five or six different suggestions from those posts and have had no luck.
When trying
git push heroku master
I get the following error:
(env) PS C:\Users\Shaun\Desktop\DjangoBlog\src> git push heroku master
Total 0 (delta 0), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to murmuring-dusk-96030.
remote:
To https://git.heroku.com/murmuring-dusk-96030.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/murmuring-dusk-96030.git'
From the build log on the Heroku website:
-----> 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 have a simple static website running Django 2.2.3 as back end. I've been developing in a virtual environment on my local machine and have the following project structure shown blow, where src/ was what I renamed the folder created by the django-admin startproject command.
I'd like to deploy my site on Heroku so I've signed up, installed Git and the Heroku CLI. In my terminal I've logged in to Heroku and initialized my Git repository in this top level root (src/). I've added a Procfile which contains the following:
web: gunicorn blog.wsgi --log-file -
I have the following in my runtime.txt file. I'm actually running 3.7.3 in my virtual environment but I've tried both ways:
python-3.6.1
To settings I added:
import django_heroku
MIDDLEWARE = [
# added this:
'whitenoise.middleware.WhiteNoiseMiddleware',
]
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
# Add configuration for static files storage using whitenoise
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
django_heroku.settings(locals())
My requirements.txt contains all packages I'm using and psycopg2, whitenoise and gunicorn, django-heroku.
I'm not sure what I'm doing wrong exactly, any help would be appreciated.
Your requirements.txt, along with your Procfile and runtime.txt, must be in the top-level root directory of your project.
Move them there, commit that change, and deploy again, e.g.
cd $PROJECT_ROOT
git mv src/requirements.txt .
git mv src/Procfile .
git mv src/runtime.txt .
git commit -m 'Move requirements.txt and Heroku files to root'
git push heroku master
I'm trying to install a django app to Heroku for the first time. I've been following tutorials and things were going fine until git push heroku master. I get an error with postgrequl/psycopg2:
Collecting psycopg2==2.6.2 (from -r /tmp/build_9a1b9401a05f6186e32ef1f993bdd183/requirements.txt (line 10))
remote: Downloading blah...blah../bc/psycopg2-2.6.2.tar.gz (376kB)
remote: Complete output from command python setup.py egg_info:
remote: running egg_info
remote: creating pip-egg-info/psycopg2.egg-info
remote: writing pip-egg-info/psycopg2.egg-info/PKG-INFO
remote: writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
remote: writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
remote: writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
remote: Error: could not determine PostgreSQL version from '10.5'
remote:
remote: ----------------------------------------
remote: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-mu5yzi1s/psycopg2/
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to django-randomizer.
I did some searches and I read where other people had problems because they had an older version of psycopg2. So I edited my requirements.txt file to include psycopg2-2.7.5, which is the latest. I think try `git push heroku master' again and I get the same error. The error references psycopg2-2.6.2.
I even deleted my app and started again, but when it came to the git push, I get the same error. At this time I think that git is in some state where it keeps trying to do the push that already failed. I'm not sure though. Any ideas?
git reflog:
5fd142e (HEAD -> deployheroku, origin/deployheroku) HEAD#{0}: pull origin deployheroku: Fast-forward
df048a9 (origin/master, origin/HEAD, master) HEAD#{1}: reset: moving to HEAD^
5fd142e (HEAD -> deployheroku, origin/deployheroku) HEAD#{2}: commit: change settings and wsgi for heroku
df048a9 (origin/master, origin/HEAD, master) HEAD#{3}: checkout: moving from master to deployheroku
df048a9 (origin/master, origin/HEAD, master) HEAD#{4}: commit: restore local version
873d636 HEAD#{5}: commit: updated psycopg2 in requirements.txt
aebfe43 HEAD#{6}: commit: get files ready for heroku
6273553 HEAD#{7}: commit: removed old files
9b2c347 HEAD#{8}: commit: update with new app name
6b4103d HEAD#{9}: clone: from https://github.com/shmish/django-randomizer.git
My requirements.txt is:
certifi==2018.8.13
chardet==3.0.4
defusedxml==0.5.0
Django==2.0.8
django-allauth==0.36.0
django-filter==2.0.0
docopt==0.6.2
idna==2.7
oauthlib==2.1.0
psycopg2==2.7.5
python-decouple==3.1
python3-openid==3.1.0
pytz==2018.5
requests==2.19.1
requests-oauthlib==1.0.0
urllib3==1.23
whitenoise==4.0
yarg==0.1.9
$ git show master:requirements.txt | grep psycopg2
psycopg2==2.6.2
So you've deployed a wrong branch. Either deploy deployheroku or update requirements.txt in master.
I'm trying to deploy a large django project to heroku. I installed Heroku CLI, logged in, created an app and ran:
git push heroku master
I have a Pipfile and requirements.txt already set up. I added a runtime.txt to specify that I need python 2.7. This is also in the Pipfile. This is what I get from pushing to heroku:
Counting objects: 12159, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4853/4853), done.
Writing objects: 100% (12159/12159), 20.94 MiB | 1.82 MiB/s, done.
Total 12159 (delta 6859), reused 12036 (delta 6751)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.6.4
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 11.8.2…
remote: Your Pipfile.lock (3b2ba9) is out of date. Expected: (83a5b4).
remote: Aborting deploy.
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy....
remote:
remote: ! Push rejected to camp-infinity.
remote:
To https://git.heroku.com/camp-infinity.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/camp-infinity.git'
I'm not sure why it tries to install python 3, and it also doesn't like my Pipfile.lock file. I've tried deleting it and generating it again with pipenv install but that didn't change anything.
Make sure you have initialised your environment in Python 2.X with pipenv --two, then - given your code runs locally and all dependencies are specified in your Pipfile - run pipenv install and commit all changes including the Pipfile.lock to your local git repo (git add * && git commit -m "your message"). Finally push to heroku. Hope it now builds correctly.