Search code examples
pythonherokupipgoogle-cloud-speech

heroku pip requirements.txt google-cloud-speech fails


I have a requirements.txt in my python/django project. Everything has worked fine, locally as well, until I tried to include google-cloud-speech in my requirements and deploying to heroku. It has failed since then and I'm not sure why. (I have deployed to heroku numerous times before this)

I'm following this example here: https://cloud.google.com/speech-to-text/docs/libraries

Test locally, everything compiles and endpoints work correctly with the imports of:

from google.cloud import speech_v1p1beta1
from google.cloud.speech_v1p1beta1 import enums

Steps to reproduce: In my virtualenv

pip install -r requirements.txt
python manage.py runserver [works]
run endpoint for speech transcription [works]
git push heroku master [fails]

Here's the output:

remote:      $ pip install -r requirements.txt
remote:        Collecting google-cloud-speech==1.3.2 (from -r requirements.txt (line 25))
remote:          Downloading https://files.pythonhosted.org/packages/5c/4b/76ec278f9ac5b6a525d222d7539cc473cca41f639a571177301a5115d0b3/google_cloud_speech-1.3.2-py2.py3-none-any.whl (88kB)
remote:        Collecting setuptools==49.2.0 (from -r requirements.txt (line 50))
remote:          Downloading https://files.pythonhosted.org/packages/8e/11/9e10f1cad4518cb307b484c255cae61e97f05b82f6d536932b1714e01b47/setuptools-49.2.0-py3-none-any.whl (789kB)
remote:        Collecting pip>=9.0.1 (from pipenv==2018.11.26->-r requirements.txt (line 36))
remote:          Downloading https://files.pythonhosted.org/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl (1.5MB)
remote:        Collecting grpcio<2.0dev,>=1.29.0 (from google-api-core[grpc]<2.0.0dev,>=1.14.0->google-cloud-speech==1.3.2->-r requirements.txt (line 25))
remote:          Downloading https://files.pythonhosted.org/packages/5e/29/1bd649737e427a6bb850174293b4f2b72ab80dd49462142db9b81e1e5c7b/grpcio-1.30.0.tar.gz (19.7MB)
remote:        Exception:
remote:        Traceback (most recent call last):
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/pip-8.1.1-py3.6.egg/pip/_vendor/pkg_resources/__init__.py", line 2610, in _dep_map
remote:            return self.__dep_map
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/pip-8.1.1-py3.6.egg/pip/_vendor/pkg_resources/__init__.py", line 2685, in __getattr__
remote:            raise AttributeError(attr)
remote:        AttributeError: _Distribution__dep_map
remote:        
remote:        During handling of the above exception, another exception occurred:
remote:        
remote:        Traceback (most recent call last):
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/pip-8.1.1-py3.6.egg/pip/basecommand.py", line 209, in main
remote:            status = self.run(options, args)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/pip-8.1.1-py3.6.egg/pip/commands/install.py", line 299, in run
remote:            requirement_set.prepare_files(finder)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/pip-8.1.1-py3.6.egg/pip/req/req_set.py", line 360, in prepare_files
remote:            ignore_dependencies=self.ignore_dependencies))
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/pip-8.1.1-py3.6.egg/pip/req/req_set.py", line 647, in _prepare_file
remote:            set(req_to_install.extras) - set(dist.extras)
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/pip-8.1.1-py3.6.egg/pip/_vendor/pkg_resources/__init__.py", line 2810, in extras
remote:            return [dep for dep in self._dep_map if dep]
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/pip-8.1.1-py3.6.egg/pip/_vendor/pkg_resources/__init__.py", line 2624, in _dep_map
remote:            dm.setdefault(extra,[]).extend(parse_requirements(reqs))
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/pip-8.1.1-py3.6.egg/pip/_vendor/pkg_resources/__init__.py", line 2980, in parse_requirements
remote:            "version spec")
remote:          File "/app/.heroku/python/lib/python3.6/site-packages/pip-8.1.1-py3.6.egg/pip/_vendor/pkg_resources/__init__.py", line 2956, in scan_list
remote:            raise RequirementParseError(msg, line, "at", line[p:])
remote:        pip._vendor.pkg_resources.RequirementParseError: Expected ',' or end-of-list in futures>=2.2.0; python_version<'3.2' at ; python_version<'3.2'
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 

Here's my requirements.txt

apns2==0.7.1
asn1crypto==1.1.0
boto3==1.9.250
botocore==1.12.251
certifi==2019.9.11
cffi==1.13.0
celery==4.4.1
chardet==3.0.4
cryptography==2.9
Django==2.2.4
django-bootstrap4==0.0.8
django-cors-headers==3.2.0
django-extensions==2.2.9
django-filter==2.2.0
django-heroku==0.3.1
django-rest-framework-social-oauth2==1.1.0
django-storages==1.7.1
djangorestframework==3.10.3
dj-database-url==0.5.0
dj-stripe==2.3.0
docutils==0.15.2
gunicorn==20.0.4
gcloud==0.18.3
google-cloud-storage==1.29.0
google-cloud-speech==1.3.2
google-api-python-client==1.10.0
h2==2.6.2
hpack==3.0.0
hyper==0.7.0
hyperframe==3.2.0
idna==2.8
jmespath==0.9.4
nltk==3.5
pandas==1.0.3
Pillow==7.1.2
pipenv==2018.11.26
psycopg2-binary
pycparser==2.19
pydub==0.24.1
PyJWT==1.7.1
python-dateutil==2.8.0
pytest==5.4.1
pytest-django==3.8.0
pytz==2019.2
redis==3.4.1
requests==2.22.0
rest-social-auth==2.0.2
s3transfer==0.2.1
sendgrid==6.3.1
six==1.12.0
stripe==2.48.0
sqlparse==0.3.0
urllib3==1.24.3
virtualenv==16.7.6
virtualenv-clone==0.5.3

Solution

  • I ended up having to downgrade my versions of grpcio and google-core-api to resolve this. Lots of trial and error so I don't really have a root cause to share unfortunately.