jjzjj

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

coder 2023-08-19 原文

一个 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/

有关python - Heroku ---> 安装 pip 远程 : AttributeError: module 'pip._vendor.requests' has no attribute 'Session'的更多相关文章

  1. ruby - Facter::Util::Uptime:Module 的未定义方法 get_uptime (NoMethodError) - 2

    我正在尝试设置一个puppet节点,但ruby​​gems似乎不正常。如果我通过它自己的二进制文件(/usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter)在cli上运行facter,它工作正常,但如果我通过由ruby​​gems(/usr/bin/facter)安装的二进制文件,它抛出:/usr/lib/ruby/1.8/facter/uptime.rb:11:undefinedmethod`get_uptime'forFacter::Util::Uptime:Module(NoMethodError)from/usr/lib/ruby

  2. python - 如何使用 Ruby 或 Python 创建一系列高音调和低音调的蜂鸣声? - 2

    关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。

  3. ruby-on-rails - rails : "missing partial" when calling 'render' in RSpec test - 2

    我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou

  4. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  5. ruby - 如何每月在 Heroku 运行一次 Scheduler 插件? - 2

    在选择我想要运行操作的频率时,唯一的选项是“每天”、“每小时”和“每10分钟”。谢谢!我想为我的Rails3.1应用程序运行调度程序。 最佳答案 这不是一个优雅的解决方案,但您可以安排它每天运行,并在实际开始工作之前检查日期是否为当月的第一天。 关于ruby-如何每月在Heroku运行一次Scheduler插件?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/8692687/

  6. ruby-on-rails - Rails 3.2.1 中 ActionMailer 中的未定义方法 'default_content_type=' - 2

    我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer

  7. ruby - 在 jRuby 中使用 'fork' 生成进程的替代方案? - 2

    在MRIRuby中我可以这样做:deftransferinternal_server=self.init_serverpid=forkdointernal_server.runend#Maketheserverprocessrunindependently.Process.detach(pid)internal_client=self.init_client#Dootherstuffwithconnectingtointernal_server...internal_client.post('somedata')ensure#KillserverProcess.kill('KILL',

  8. ruby - 主要 :Object when running build from sublime 的未定义方法 `require_relative' - 2

    我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby​​1.9+ 关于ruby-主要:Objectwhenrun

  9. ruby - 无法让 RSpec 工作—— 'require' : cannot load such file - 2

    我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳

  10. ruby-on-rails - 新 Rails 项目 : 'bundle install' can't install rails in gemfile - 2

    我已经像这样安装了一个新的Rails项目:$railsnewsite它执行并到达:bundleinstall但是当它似乎尝试安装依赖项时我得到了这个错误Gem::Ext::BuildError:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcheckingforlibkern/OSAtomic.h...yescreatingMakefilemake"DESTDIR="cleanmake"DESTDIR="

随机推荐