Heroku Django app deployment fails after trying to install python requirement - python

I installed django-user-visit with pip install django-user-visit , tested it in my local environment and everything seems to work fine, but when i try to deploy my app to production with Heroku i get the following error :
remote: Collecting django-cors-headers==3.6.0
remote: Downloading django_cors_headers-3.6.0-py3-none-any.whl (12 kB)
remote: ERROR: Could not find a version that satisfies the requirement django-user-visit==0.4.1 (from -r /tmp/build_940d12d0/requirements.txt (line 4)) (from versions: none)
remote: ERROR: _No matching distribution_ found for django-user-visit==0.4.1 (from -r /tmp/build_940d12d0/requirements.txt (line 4))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
Does anyone know why Heroku can't find the package and if i can fix this ?
My packages are being installed by running the libraries indicated in my requirements.txt file:
asgiref==3.3.1
Django==3.1.5
django-cors-headers==3.6.0
django-user-visit==0.4.1
djangorestframework==3.12.2
gunicorn==20.0.4
psycopg2==2.8.6
pytz==2020.5
sqlparse==0.4.1
ua-parser==0.10.0
user-agents==2.2.0
whitenoise==5.2.0
What i've tried so far is to change the version to 0.4 and to not specify a version at all

From the documentation: https://devcenter.heroku.com/articles/python-runtimes
If you’re running a Python application that requires a different supported runtime, or if you simply want to lock your project against patch updates until you’re ready to upgrade, you can specify which runtime to use for your app.
To specify a Python runtime, add a runtime.txt file to your app’s root directory that declares the exact version number to use.
after that
pip freeze > requirements.txt

Related

Heroku git master push

I'm new to heroku, but I've been following the documentation to the letter. I am deploying my dash app to heroku. The setup was going well until the final master push
> (venv) -MacBook-Air-3 heroku % git push heroku master
Enumerating objects: 12155, done.
Counting objects: 100% (12155/12155), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2900/2900), done.
Writing objects: 100% (12155/12155), 15.08 MiB | 1.53 MiB/s, done.
Total 12155 (delta 9145), reused 12155 (delta 9145)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Python app detected
remote: -----> Installing python-3.6.12
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: Could not find a version that satisfies the requirement hBrotli==1.0.9
(from -r /tmp/build_77052133/requirements.txt (line 1)) (from versions: none)
remote: ERROR: No matching distribution found for hBrotli==1.0.9 (from -r /tmp/build_77052133/requirements.txt (line 1))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
I went to the requirements.txt that I created with pip3 freeze >requirements.txt as per the documentation and indeed on line 1 there was hBrotli== 1.0.9. I am not familiar with hBrotli and don't use it for my code and can't seem to find any information about it. I'm not sure what the error message is implying.
there is no package named hBrotli it may be due to some typo just change hBrotli to Brotli
This is the package that you are looking for https://pypi.org/project/Brotli/ so just change the hBrotli to Brotli
Or just do pip install Brotli
Also if needed change imports into from brotli import nameOfClass

How to fix error "'django-admin' is not recognized as an internal or external command"?

This is the code I've tried so far.
I tried updating it using git clone https://github.com/django/django.git but the error is the same:
C:\Users\HP>pip install django
Requirement already satisfied: django in c:\users\hp\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (3.0.7)
Requirement already satisfied: asgiref~=3.2 in c:\users\hp\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from django) (3.2.7)
Requirement already satisfied: pytz in c:\users\hp\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from django) (2020.1)
Requirement already satisfied: sqlparse>=0.2.2 in c:\users\hp\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from django) (0.3.1)
C:\Users\HP>python -m django --version
3.0.7
C:\Users\HP>django-admin
'django-admin' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\HP>git clone https://github.com/django/django.git
Cloning into 'django'...
remote: Enumerating objects: 82, done.
remote: Counting objects: 100% (82/82), done.
remote: Compressing objects: 100% (72/72), done.
remote: Total 458425 (delta 35), reused 19 (delta 10), pack-reused 458343 receiving objects: 100% (458425/458425), 191.37Receiving83 MiB/s
objects: 100% (458425/458425), 192.20 MiB | 1.85 MiB/s, done.
Resolving deltas: 100% (335466/335466), done.
Updating files: 100% (6266/6266), done.
C:\Users\HP>django-admin
'django-admin' is not recognized as an internal or external command,
operable program or batch file.
Django may not work on python3.8(latest version)
So you should use conda or virtual environment.
If you use conda, pls do like this
conda create --name mydjango python=3.7
conda activate mydjango
then you will be go into python3.7 environment instead 3.8
then Install django using this command 'pip install django'
Use a virtual environment where you install Django and all other packages you need for your project. then you'll know for sure django-admin will be available as expected.

Could not find a version that satisfies the requirement pywin32==227 heroku

I am having this issue with heroku.
i am trying to push my application to heroku but
it seems that heroku can not install pywin32=227 but i do not know why is this happening.
i hope that someone can help me whit this issue.
Requirements.txt:
appdirs==1.4.3
asgiref==3.2.3
awsebcli==3.17.1
botocore==1.14.17
cement==2.8.2
certifi==2019.11.28
chardet==3.0.4
colorama==0.3.9
distlib==0.3.0
dj-database-url==0.5.0
Django==2.1.15
django-pyodbc-azure==2.1.0.0
docutils==0.15.2
filelock==3.0.12
future==0.16.0
gunicorn==20.0.4
idna==2.7
importlib-metadata==1.5.0
jmespath==0.9.5
pathspec==0.5.9
Pillow==7.0.0
psycopg2==2.8.4
pyodbc==4.0.30
pypiwin32==223
python-dateutil==2.8.0
python-decouple==3.3
pytz==2019.3
pywin32==227
PyYAML==5.2
requests==2.20.1
semantic-version==2.5.0
six==1.11.0
sqlparse==0.3.1
stripe==2.43.0
termcolor==1.1.0
urllib3==1.24.3
virtualenv==20.0.7
wcwidth==0.1.8
whitenoise==5.0.1
zipp==3.1.0
I'm developing on Windows 10 Professional, and the application works fine there:
C:\Users\GuGarza\test>git push heroku master
Enumerating objects: 363, done.
Counting objects: 100% (363/363), done.
Delta compression using up to 4 threads
Compressing objects: 100% (348/348), done.
Writing objects: 100% (363/363), 257.21 KiB | 1.42 MiB/s, done.
Total 363 (delta 107), reused 0 (delta 0)
remote: Downloading pytz-2019.3-py2.py3-none-any.whl (509 kB)
remote: ERROR: Could not find a version that satisfies the requirement pywin32==227 (from -r
/tmp/build_000de559e8272ea11b28b5ee568bf649/requirements.txt (line 28)) (from versions: none)
remote: ERROR: No matching distribution found for pywin32==227 (from -r
/tmp/build_000de559e8272ea11b28b5ee568bf649/requirements.txt (line 28))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to memotion.
remote:
To https://git.heroku.com/memotion.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/memotion.git'
I got the same error while deploying flask app in azure app server.
Removing/commentting out pywin32==227 in requirements.txt worked for me.
Conditional dependencies is a better choice in this situation. This way you don't break things on Windows.
Add ;platform_system == "Windows" right after the Windows-only packages
I had the same problem in Pycharm.
Installing new version or packages like pypiwin32 did not work as described above.
Removing packages from the req file did not work either.
I copied my dev files, then I deleted the project.
I set up a completely new project and copied the Py files into it.
It worked.
The cause for the error message above was:
I did corrupt my project by trying to install chart_studio with pip, which did not work. It only works with Conda.
This corrupted my req and my site packages.

Heroku push rejected, error says python 2.7.14 is unsupported, even though it is

I've created an interactive bokeh plot that I'm trying to serve with Heroku. I went through the "Getting Started on Heroku with Python" tutorial, and am also following this example. With appropriate Procfile settings, I can run the Heroku app locally just fine. I've specified the Python version in both runtime.txt AND Pipfile as 2.7.14, and that's my local version as well. But when I try to push to the Heroku server, I get the following error message
remote: -----> Python app detected
remote: ! The latest version of Python 3 is python-3.6.4 (you are using # runtime.txt
remote: python-2.7.14, which is unsupported).
remote: ! We recommend upgrading by specifying the latest version (python-3.6.4).
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing # runtime.txt
remote: python-2.7.14
remote: ! Requested runtime (# runtime.txt
remote: python-2.7.14) 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
The Heroku docs (at the very link given in the error message!) say that Python 2.7.14 is in fact supported. Is there something I'm missing here, like somewhere else I need to specify the python version?
My full code is here for reference.
Edit: I wrote Procfile when I meant Pipfile.
Your are supposed to specifiy python version in Pipfile. From their site
You can specify the runtime python-2.7.14, if you wish, with a Pipfile
$ cat Pipfile
[requires]
python_full_version = "2.7.14"
Thanks to some help on Twitter, I've found the answer. I didn't need to define the python version in both Pipfile AND runtime.txt. I had tried to just have runtime.txt and got the same result, but having just the Pipfile definition let me push to Heroku and the build was successful.

Defining a correct requirements.txt file

I have developed a Flask web application that works on my local computer but which I am now trying to port onto the web (via IBM Bluemix). My first attempt to do so was unsuccessful. The error message I receive is:
Server error, status code: 400, error code: 170001, message: Staging error: no available stagers
When I check the log files with cf logs myapp --recent I find:
2015-11-08T15:34:15.92-0500 [STG/35] OUT -----> Downloaded app package (72K)
2015-11-08T15:34:19.98-0500 [STG/35] OUT -----> Downloaded app buildpack cache (39M)
2015-11-08T15:34:24.82-0500 [STG/0] OUT -------> Buildpack version 1.3.1
2015-11-08T15:34:40.57-0500 [STG/0] OUT -----> Installing dependencies with pip
2015-11-08T15:34:41.54-0500 [STG/0] OUT You are using pip version 6.1.0.dev0, however version 7.1.2 is available.
2015-11-08T15:34:41.54-0500 [STG/0] OUT You should consider upgrading via the 'pip install --upgrade pip' command.
2015-11-08T15:34:41.56-0500 [STG/0] OUT Collecting flask.ext.wtf (from -r requirements.txt (line 2))
2015-11-08T15:34:41.88-0500 [STG/0] OUT Could not find a version that satisfies the requirement flask.ext.wtf (from -r requirements.txt (line 2)) (from versions: )
2015-11-08T15:34:41.88-0500 [STG/0] OUT No matching distribution found for flask.ext.wtf (from -r requirements.txt (line 2))
2015-11-08T15:34:41.96-0500 [STG/0] OUT Staging failed: Buildpack compilation step failed
2015-11-08T15:34:41.97-0500 [STG/0] ERR
2015-11-08T15:34:42.67-0500 [API/2] ERR encountered error: App staging failed in the buildpack compile phase
2015-11-08T15:35:37.75-0500 [API/3] OUT Updated app with guid b580bb64-4415-4bb4-8fd1-1e4d3de4f7d9 ({"name"=>"cultural-insight", "memory"=>128, "environment_json"=>"PRIVATE DATA HIDDEN"})
2015-11-08T15:35:49.95-0500 [API/3] OUT Updated app with guid b580bb64-4415-4bb4-8fd1-1e4d3de4f7d9 ({"state"=>"STOPPED"})
2015-11-08T15:35:52.41-0500 [DEA/113] OUT Got staging request for app with id b580bb64-4415-4bb4-8fd1-1e4d3de4f7d9
2015-11-08T15:35:52.47-0500 [API/0] ERR exception handling first response Staging error: failed to stage application:
2015-11-08T15:35:52.47-0500 [API/0] ERR Not enough memory resources available
2015-11-08T15:50:52.42-0500 [API/0] ERR encountered error: Staging error: failed to stage application: staging had already been marked as failed, this could mean that staging took too long
The problem appears to be that pip can't find Flask-WTF, which I need for my application to work.
I installed Flask-WTF on my local machine with pip install Flask-WTF. The contents of requirements.txt, which the builder ingests while setting up, is simply:
Flask==0.10.1
Flask-WTF
In particular, I am unsure why pip is asking for flask.ext.wtf? Additionally it is troubling me that the application says it is limited to 128 MB, when I bumped it up to 512 MB.
Altogether, I'm not sure what's going on. How do I resolve this issue? The full source code is here.
run this (EDITED):
pip install --upgrade pip
and update your requirements.txt file:
pip freeze > requirements.txt

Categories