gpt4 book ai didi

python - Heroku ---> 安装 pip 远程 : AttributeError: module 'pip._vendor.requests' has no attribute 'Session'

转载 作者:太空狗 更新时间:2023-10-29 20:13:22 26 4
gpt4 key购买 nike

一个 Python 3.6 Django ==11 应用程序正在部署,并且代码会定期推送到昨天。现在我有错误:

remote: AttributeError: module 'pip._vendor.requests' has no attribute 'Session'

整个轨迹:

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'

另一个问题——如上所示,我知道的是默认构建 DIR 中不存在 OpenCv [cv2]。我正在为此部署 Python OpenCV buildpack - 但需要先解决此问题:

File "/tmp/build_989d7449dd0cd18694a87448cb09f19f/indexapp/image_processing.py", line 7, in <module>
remote: import cv2
remote: ModuleNotFoundError: No module named 'cv2'

最佳答案

我刚刚遇到了同样的错误:

AttributeError: module 'pip._vendor.requests' has no attribute 'Session'

清除 Heroku 构建缓存为我解决了这个问题。这是您需要执行的操作:

  1. 安装官方heroku-repo plugin for the Heroku CLI :

    $ heroku plugins:install heroku-repo
  2. 清除应用的构建缓存:

    $ heroku repo:purge_cache -a APPNAME
  3. 触发部署以重建您的应用

清除构建缓存会导致 pip 在下一次构建时从头开始重新安装 Python 依赖项,而不是尝试升级当前的依赖项集。

这为我解决了 AttributeError,希望对您有所帮助!

关于python - Heroku ---> 安装 pip 远程 : AttributeError: module 'pip._vendor.requests' has no attribute 'Session' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49833273/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com