Une application Python 3.6 Django == 11 était en cours de déploiement et le code régulièrement poussé jusqu'à hier. Maintenant j'ai l'erreur:
remote: AttributeError: le module 'pip._vendor.requests' n'a pas d'attribut 'Session'
Trace entière:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 273 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing pip
remote: Traceback (most recent call last):
remote: File "/app/tmp/buildpacks/779a8bbfbbe7e1b715476c0b23fc63a2103b3e4131eda558669aba8fb5e6e05682419376144189b29beb5dee6d7626b4d3385edb0954bffea6c67d8cf622fd51/vendor/pip-pop/pip-diff", line 15, in <module>
remote: from pip.req import parse_requirements
remote: File "/app/.heroku/python/lib/python3.6/site-packages/pip/req/__init__.py", line 3, in <module>
remote: from .req_install import InstallRequirement
remote: File "/app/.heroku/python/lib/python3.6/site-packages/pip/req/req_install.py", line 25, in <module>
remote: import pip.wheel
remote: File "/app/.heroku/python/lib/python3.6/site-packages/pip/wheel.py", line 28, in <module>
remote: from pip.download import path_to_url, unpack_url
remote: File "/app/.heroku/python/lib/python3.6/site-packages/pip/download.py", line 40, in <module>
remote: from pip._vendor import requests, six
remote: File "/app/.heroku/python/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 83, in <module>
remote: from pip._internal.compat import WINDOWS
remote: File "/app/.heroku/python/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
remote: from pip._internal import cmdoptions
remote: File "/app/.heroku/python/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
remote: from pip._internal.index import (
remote: File "/app/.heroku/python/lib/python3.6/site-packages/pip/_internal/index.py", line 25, in <module>
remote: from pip._internal.download import HAS_TLS, is_url, path_to_url, url_to_path
remote: File "/app/.heroku/python/lib/python3.6/site-packages/pip/_internal/download.py", line 326, in <module>
remote: class PipSession(requests.Session):
remote: AttributeError: module 'pip._vendor.requests' has no attribute 'Session'
remote: mount: failure.bad-requirements: No such file or directory
remote: -----> Installing requirements with pip
remote:
remote: -----> $ python manage.py collectstatic --noinput
remote: Traceback (most recent call last):
remote: File "manage.py", line 22, in <module>
remote: execute_from_command_line(sys.argv)
remote: File "/app/.heroku/python/lib/python3.6/site-packages/Django/core/management/__init__.py", line 363, in execute_from_command_line
remote: utility.execute()
remote: File "/app/.heroku/python/lib/python3.6/site-packages/Django/core/management/__init__.py", line 337, in execute
remote: Django.setup()
remote: File "/app/.heroku/python/lib/python3.6/site-packages/Django/__init__.py", line 27, in setup
remote: apps.populate(settings.INSTALLED_APPS)
remote: File "/app/.heroku/python/lib/python3.6/site-packages/Django/apps/registry.py", line 108, in populate
remote: app_config.import_models()
remote: File "/app/.heroku/python/lib/python3.6/site-packages/Django/apps/config.py", line 202, in import_models
remote: self.models_module = import_module(models_module_name)
remote: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
remote: return _bootstrap._gcd_import(name[level:], package, level)
remote: File "<frozen importlib._bootstrap>", line 994, in _gcd_import
remote: File "<frozen importlib._bootstrap>", line 971, in _find_and_load
remote: File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
remote: File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
remote: File "<frozen importlib._bootstrap_external>", line 678, in exec_module
remote: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
remote: File "/tmp/build_989d7449dd0cd18694a87448cb09f19f/indexapp/models.py", line 9, in <module>
remote: from .image_processing import *
remote: File "/tmp/build_989d7449dd0cd18694a87448cb09f19f/indexapp/image_processing.py", line 7, in <module>
remote: import cv2
remote: ModuleNotFoundError: No module named 'cv2'
remote:
remote: ! Error while running '$ python manage.py collectstatic --noinput'.
remote: See traceback above for details.
remote:
remote: You may need to update application code to resolve this error.
remote: Or, you can disable collectstatic for this application:
remote:
remote: $ heroku config:set DISABLE_COLLECTSTATIC=1
remote:
remote: https://devcenter.heroku.com/articles/Django-assets
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to Django-rest-api-comp-vision.
remote:
To https://git.heroku.com/Django-rest-api-comp-vision.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to Push some refs to 'https://git.heroku.com/Django-rest-api-comp-vision.git'
Comme je l’ai vu plus haut, OpenCv [cv2] n’est pas présent dans le répertoire de génération par défaut, par exemple. Je suis en train de déployer un buildpack Python OpenCV pour la même chose - mais il faut que ce problème soit résolu en premier
File "/tmp/build_989d7449dd0cd18694a87448cb09f19f/indexapp/image_processing.py", line 7, in <module>
remote: import cv2
remote: ModuleNotFoundError: No module named 'cv2'
Je viens de rencontrer la même erreur:
AttributeError: module 'pip._vendor.requests' has no attribute 'Session'
Effacer le cache de construction Heroku a résolu le problème pour moi. Voici ce que vous devez faire:
Installez le plugin officiel heroku-repo
pour le CLI Heroku :
$ heroku plugins:install heroku-repo
Effacez le cache de construction de votre application:
$ heroku repo:purge_cache -a APPNAME
Déclencher un déploiement pour reconstruire votre application
Effacer le cache de construction amène pip à réinstaller entièrement vos dépendances Python lors de la prochaine construction au lieu de tenter de mettre à niveau votre ensemble de dépendances actuel.
Ceci a résolu la AttributeError
pour moi, espérons que cela aide!
Pour me débarrasser de cela, je viens de changer from pip._vendor import requests
en import requests
J'ai trouvé la solution ici: GitHub: AttributeError: le module 'pip._vendor.requests' n'a pas d'attribut 'Session' # 5267