Pushing a python app to Heroku, I'm getting this:
! The package setuptools/distribute is listed in requirements.txt.
! Please remove to ensure expected behavior.
The docs explicitly include distribute in their requirements.txt files, and when I remove it, I get this (which sure seems to depend on distribute):
Traceback (most recent call last):
File "/app/.heroku/python/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
! Push rejected, failed to compile Python app
This question is crazy old, but for anyone who stumbles upon this and still needs an answer, you should try upgrading your Heroku buildpack (the collection of scripts that build your app on the dynos). This will update pip (among other things), since you can't exactly do what Mauro suggested because the code is being deployed to Heroku dynos.
More info on buildpacks: https://devcenter.heroku.com/articles/buildpacks
But if you don't want to read the article, just do
$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-python
Then re-attempt to deploy your app like normal.
Upgrade setuptools and distribute.
pip install --upgrade setuptools
pip install --upgrade distribute
Update your requirements.txt. This worked for me exactly yesterday.
Related
I am getting the following error when I try to run the backend of my web application: ImportError: cannot import name 'run_with_reloader' from 'werkzeug.serving'. It is coming from within the \lib\site-packages\werkzeug\serving.py file. I think it has to do with the line from flask_socketio import SocketIO inside my server file. Any ideas?
This error has been addressed, so you are very likely using an old version of Flask-SocketIO. Once you upgrade the error should go away.
I needed to keep using flask-socketio v4 (for older socketio.js) and pinning to 2.0.x version of Werkzeug fixed this problem
--- a/python-flask-socketio-server/requirements.txt
+++ b/python-flask-socketio-server/requirements.txt
## -1,4 +1,5 ##
flask
+Werkzeug==2.0.1
flask-socketio==4.3.2
# wheel should not be needed, but avoids pyyaml paho-mqtt bdist_wheel error
wheel
Note: I also needed to tell pip to not use cached packages, or else it would still pull in problematic 2.1.x version to virtualenv that was being regenerated.
pip install --no-cache-dir -r requirements.txt
Solution is to install the following Werkzeug version (Werkzeug-0.10.2.dev0dev-20220510) along with the following versions: [Tested in MacOS]
pip3 install Flask-SocketIO==4.3.1
pip3 install python-engineio==3.13.2
pip3 install python-socketio==4.6.0
pip3 install git+https://github.com/untitaker/werkzeug.git#reloader-perf
I had to downgrade Werkzeug and Flask to avoid this error. When Flask-SocketIO is involved, you may need to stick with older versions to avoid incompatibility issues with newer versions of Flask.
The combination that works for me is:
Flask-SocketIO==4.3.1
python-engineio==3.13.2
python-socketio==4.6.0
Flask==2.0.3
Werkzeug==2.0.3
I'm deploying a application on Heroku and that application needs Torch module to install on the server and I'm unable to push the app using git because of this error....
I tried many methods but unable to push it...
Tell me what should I write in the requirements.txt in order to install torch
You need to write the url of wheel file (from torch_stable.html) of torch (and torchvision, if required) corresponding to the required version in your requirements.txt file. Then, pip will install the wheel file.
e.g.
https://download.pytorch.org/whl/cpu/torch-1.5.0%2Bcpu-cp37-cp37m-linux_x86_64.whl
The above file corresponds to pytorch (cpu) 1.5, python 3.7, linux.
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.
I've just created a Google Cloud compute engine, installed google-cloud package with both pip and pip3, and I'm experiencing the following error when launching a script with python3
from google.cloud import bigquery
File "/usr/local/lib/python3.5/dist-packages/google/cloud/bigquery/__init__.py", line 35,
in <module>
from google.cloud.bigquery.client import Client
File "/usr/local/lib/python3.5/dist-packages/google/cloud/bigquery/client.py", line 36, in
<module>
(more traceback lines..)
from pyasn1_modules.rfc2459 import Certificate
File "/usr/local/lib/python3.5/dist-packages/pyasn1_modules/rfc2459.py", line 20, in <modu
le>
from pyasn1.type import opentype
ImportError: cannot import name 'opentype'
On the compute engine the following packages are installed:
pyasn1==0.1.9
pyasn1-modules==0.2.1
google-cloud==0.30.0
google-cloud-bigquery==0.28.0
Which can be the problem here?
Posting my solution in case it helps someone else - this fixed it for me:
pip install --upgrade google-auth-oauthlib
More details discussed here: https://www.raspberrypi.org/forums/viewtopic.php?f=114&t=198933&p=1241439#p1241439
It looks like you have an issue with pyasn1, so you could try installing a newer version (the latest is 0.4.2), or even reinstalling it manually with:
sudo apt-get --reinstall install python-pyasn1 python-pyasn1-modules
And if you are inside a virtualenv, use instead:
pip install pyasn1 pyasn1-modules
FWIW - Had the same issue - none of the above worked. I eventually discovered that if I did it under sudo it did work.
stracing the original - I found that I had a ~/.local directory which had a pyasn1 directory where it was trying to get the files from, but the opentype.py one did not appear there. When I deleted that whole directory - it started working.
I assume it was some sort of cache that was partial, and out-of-date???
I have a server in the AWS cloud. It was running a flask API which calls the Google STT API fine. I then attempted to 'productionise' the API by setting up a virtualenv and getting the API to run there, with the intent of running Gunicorn.
When I tried to run the API in the virtual container it gave an error about importing the google api client. There was no google api client folder in my virtualenv so I copied folders across from the main python2.7 site-packages folder. Then I got an error saying it could not import six in googleapiclient/discovery.py. The error was "ImportError: No module named six".
There was no six directory in my virtualenv python folder. So I tried to copy across a folder named six-1.10.0.dist-info from my main python2.7 folder but that didnt help. I tried many things...such as forcing a reinstall but still the same error with the google api reference from googleapiclient/discovery.py. So I tried "sudo pip uninstall six; sudo pip install six". This successfully uninstalled, but now I cannot install again. When I run "sudo pip install six" I get the following:
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 48, in <module>
import six
ImportError: No module named six
I have also tried easy_install and options like --upgrade --ignore-installed but with no change in the behaviour.
What the heck is going on? Why cant I reinstall six? Why would it not be recognised anyway?
UPDATE
So this post stackoverflow.com/questions/13270877/… helped me to install six back into the main python environment. My API runs fine there now. But the same approach has not worked for the virtual environment.
Running "unset PYTHONPATH" seems to have helped me install modules into the virtualenv. The AWS image seems to have come with a python path already added that was confusing virtualenv. However I am still getting the nonsense below with six. What is going on?
(myprojectenv)[ec2-user#ip-172-31-29-83 myapi]$ python api.py
Traceback (most recent call last):
File "api.py", line 3, in <module>
from googleapiclient import discovery
File "/home/ec2-user/myapi/myprojectenv/local/lib/python2.7/site-packages/googleapiclient/discovery.py", line 20, in <module>
import six
ImportError: No module named six
(myprojectenv)[ec2-user#ip-172-31-29-83 myapi]$ pip install --upgrade six
Requirement already up-to-date: six in ./myprojectenv/lib/python2.7/site-packages