- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经使用 pybrake
将 Airbrake 设置为在 Django 项目中工作,但 12 天前它停止工作,我正在尝试调试问题。
我创建了一个带有 Pipfile
和 airbrake_test.py
的小“测试项目”(我在其中打乱了项目 key 和 ID):
(pybrake_test2-cU2-tsuL) bash-3.2$ ls
Pipfile Pipfile.lock airbrake_test.py
这是airbrake_test.py
:
import os
import logging
import pybrake
os.environ['AIRBRAKE_PROJECT_ID'] = '112113'
os.environ['AIRBRAKE_PROJECT_KEY'] = '6e936fee123asdfasdf71445de0'
notifier = pybrake.Notifier(project_id=os.getenv('AIRBRAKE_PROJECT_ID'),
project_key=os.getenv('AIRBRAKE_PROJECT_KEY'),
environment='staging')
airbrake_handler = pybrake.LoggingHandler(notifier=notifier,
level=logging.ERROR)
logger = logging.getLogger('test')
logger.addHandler(airbrake_handler)
def run():
logger.error('something bad happened')
if __name__ == "__main__":
run()
这是与 pipenv
一起使用的 Pipfile
:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
pybrake = "==0.3.3"
[dev-packages]
[requires]
python_version = "3.7"
我已经测试过这有效;如果我运行脚本,我会收到关于 pybrake
无法找到 .git
目录的错误,但除此之外,没有错误:
(pybrake_test2-cU2-tsuL) bash-3.2$ python airbrake_test.py
2018-08-09 12:42:56,850 - pybrake - ERROR - get_git_revision failed: [Errno 2] No such file or directory: '/Users/kurtpeek/Documents/Scratch/pybrake_test2/.git/HEAD'
我还看到错误出现在我的 Airbrake 控制台中:
我已将完全相同的脚本复制到我的“实际”项目目录中的子目录 scripts
中(并将其命名为 airbrake_test2.py
):
(lucy-web-CVxkrCFK) bash-3.2$ find . -name 'airbrake_test2*'
./scripts/airbrake_test2.py
但是,如果我尝试运行它,我会收到“无法获取本地颁发者证书”错误:
(lucy-web-CVxkrCFK) bash-3.2$ python scripts/airbrake_test2.py
2018-08-09 12:47:08,087 - pybrake - ERROR - get_git_revision failed: [Errno 2] No such file or directory: '/Users/kurtpeek/Documents/Dev/lucy2/lucy-web/.git/HEAD'
2018-08-09 12:47:08,434 - pybrake - ERROR - <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)>
我很困惑为什么它在“测试”项目中工作,而不是在“真实”项目中工作。这是“真实”项目的 Pipfile
:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
# AWS SDK for Python
boto3 = "==1.7.61"
# Use DATABASE_URL env variable to configure Django application
dj-database-url = "==0.5.0"
# Web framework
django = "==2.0.7"
# Django email integration for transactional ESPs
"django-anymail[mailgun]" = "==3.0"
# Log of changes made to a model
django-auditlog = "==0.4.5"
# Compresses linked and inline JavaScript or CSS into a single cached file
django-compressor = "==2.2"
# Save and retrieve current request object anywhere in your code
django-crequest = "==2018.5.11"
# Blocks people from brute forcing login attempts
django-defender = "==0.5.5"
# Wrap standard Django fields with encryption
django-encrypted-model-fields = "==0.5.5"
# Custom extensions for the Django Framework
django-extensions = "==2.1.0"
# A set of high-level abstractions for Django forms
django-formtools = "==2.1"
# Import and export data in multiple formats (Excel, CSV, JSON, and so on)
django-import-export = "==1.0.1"
# Using more than one form in a single view
django-multi-form-view = "==2.0.0"
# OAuth2 for Django
django-oauth-toolkit = "==1.2.0"
# SASS integration
django-sass-processor = "==0.7"
# Collection of custom storage backends for Django
django-storages = "==1.6.6"
# Two-Factor Authentication for Django
django-two-factor-auth = "==1.7.0"
# Tweak the form field rendering in templates
django-widget-tweaks = "==1.4.2"
# Toolkit for building Web APIs
djangorestframework = "==3.8.2"
# Versioning of Django Rest Framwork API representations
djangorestframework-version-transforms = "==0.5.0"
# Fixtures replacement
factory-boy = "==2.11.1"
# Style Guide Enforcement
flake8 = "==3.5.0"
# Allows tests to travel through time by mocking the datetime module
freezegun = "==0.3.10"
# Python WSGI HTTP Server
gunicorn = "==19.9.0"
# SASS support
libsass = "==0.14.5"
# Newrelic adapter
newrelic = "==3.4.0.95"
# Parsing, formatting, and validating international phone numbers
phonenumbers = "==8.9.10"
# Imaging processing library
pillow = "==5.2.0"
# PostgreSQL adapter
psycopg2 = "==2.7.3"
# Python exception notifier for Airbrake
pybrake = "==0.3.3"
# ISO databases for languages, countries and subdivisions
pycountry = "==18.5.26"
# Extensions to the standard datetime module
python-dateutil = "==2.6.0"
# Loads environment variables from .env file
python-dotenv = "==0.8.2"
# Python wrapper for the Intercom API
python-intercom = "==3.1.0"
# HTTP library
requests = "==2.19.1"
# Python library to capitalize strings
titlecase = "==0.12.0"
# Communication with the Twilio API
twilio = "==6.15.1"
# Static file serving
whitenoise = "==3.3.1"
[dev-packages]
# Tab completion, syntax highlighting, better tracebacks for ipython
ipdb = "==0.11"
# Interactive Python shell
ipython = "==6.4.0"
[requires]
python_version = "3.7.0"
如您所见,pybrake
的版本与“测试”项目(版本 0.3.3)中的完全相同;我能想到的唯一区别是 python_version
在“测试”项目中是 3.7
而在“真实”项目中是 3.7.0
.
知道我为什么会收到此错误吗?
最佳答案
在 Airbrake 的支持下,我设法通过在 /Applications/Python 3.7
(在我的 Mac 上)中运行 Install Certificates.command
来解决问题:
Kurts-MacBook-Pro-2:Python 3.7 kurtpeek$ pwd
/Applications/Python 3.7
Kurts-MacBook-Pro-2:Python 3.7 kurtpeek$ sudo ./"Install Certificates.command"
-- pip install --upgrade certifi
The directory '/Users/kurtpeek/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/kurtpeek/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: certifi in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2018.4.16)
-- removing any existing file or link
-- creating symlink to certifi certificate bundle
-- setting permissions
-- update complete
现在 urlopen()
引发的错误已经消失了:
(lucy-web-CVxkrCFK) bash-3.2$ python scripts/airbrake_test2.py
2018-08-09 13:01:09,867 - pybrake - ERROR - get_git_revision failed: [Errno 2] No such file or directory: '/Users/kurtpeek/Documents/Dev/lucy2/lucy-web/.git/HEAD'
我再次在我们的 Airbrake 控制台中看到错误。
关于python - 减速板错误 : urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51774807/
我有一些代码使用 mechanize 和 beautifulsoup 来抓取一些数据。该代码在测试机器上运行良好,但生产机器正在阻止连接。我得到的错误是: urlopen error [Errno 1
我有一个正在测试的简单网站。它在本地主机上运行,我可以在我的网络浏览器中访问它。索引页就是简单的“运行”二字。 urllib.urlopen 将成功读取页面,但 urllib2.urlopen 不
我只是想更好地了解这里发生了什么,我当然可以使用 urllib2 来“解决”这个问题。 import urllib import urllib2 url = "http://www.crutchfie
import urllib print urllib.urlopen('http://www.reefgeek.com/equipment/Controllers_&_Monitors/Neptune
我刚刚开始编写 Python,并且遇到了 urllib 似乎是 Amazon.com 独有的问题。如果我做类似的事情: pageIn = urllib.request.urlopen("http://
我想模拟模块中对 urllib.request.urlopen 的调用。当它是单个文件时它可以工作,但是当我把它放在一个包中并在包的 __init__.py 中导入模块时,我不能再模拟它了。 复制 假
# Get the content type of a URL def get_url_type(url: str) -> str: r = urlopen(url) header = r.h
我尝试将现有 URL 作为参数传递,以将其 HTML 加载到单个 txt 文件中: for line in open('C:\Users\me\Desktop\URLS-HERE.txt'): if
我对使用 Request、urlopen 和 JSONDecoder().decode() 有点困惑。 目前我有: hdr = {'User-agent' : 'anything'} # heade
此代码用于打印网页。它现在打印一个空格,即使在浏览器中查看时该页面清楚地包含内容 from urllib.request import urlopen f = urlopen('http://onli
我刚买了 synology NAS (DS213J),我想在上面运行 python 脚本。 我的 python 脚本: 1 #!/opt/bin/python 2 3 import url
我在名为 urlopen_test() 的函数中使用 urllib.urlopen()。在这个函数中我调用了两次 urlopen,第一次调用很快,但第二次调用速度很快。有人打电话来帮我弄清楚为什么吗?
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 这个问题似乎是题外话,因为它缺乏足够的信息来诊断问题。 更详细地描述您的问题或include a min
1.data参数 data是可选的,需要使用bytes()方法将参数转化为字节编码格式的内容。如果传递了这个参数,请求方式就不是GET方式,而是POST方式。
我正在使用 迭代保存在 http 网站上的 .dat 文件 import urllib2 test_file = urllib2.urlopen('http://~/file.dat') 然后,我有一
这是我的问题: import urllib2 response=urllib2.urlopen('http://proxy-heaven.blogspot.com/') html=response.r
我没有使用 python 的经验,也没有使用下面的代码打开 url 并读取响应的经验。我收到未经授权的错误,因为该网站使用 Windows 身份验证。有人可以提供有关如何发送用户名和密码的代码示例吗?
我希望我的程序尝试打开页面并在时间间隔[0,t]内获取数据,如果该时间到期,连接应该关闭。 我正在使用urllib2来尝试完成任务。 t=1 url="http://example.com" resp
我正在尝试使用 python 程序填写表格,它对于某些网站效果很好,但对于这个特定的网站则不然,我不知道为什么。 这是代码片段 query = { 'adults':'1', 'children':'
当我使用 urllib2.urlopen() 时,我在考虑它只是为了标题读取还是实际上带回了整个网页? IE 是否在调用 urlopen 或调用 read() 时实际获取 HTML 页面? handl
我是一名优秀的程序员,十分优秀!