如何解决GeneralName TypeError?

时间:2019-06-19 19:09:52

标签: python typeerror

我正在尝试编写代码以刮擦股票网页,偶然发现了这个youtube视频https://www.youtube.com/watch?v=2BrpKpWwT2A。当我复制并粘贴以下代码(来自视频)

import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web

style.use("ggplot")
start = dt.datetime(2015, 1, 1)
end = dt.datetime.now()

df = web.DataReader("TSLA", "yahoo", start, end)
print(df.head())

我仍然遇到相同的错误(完整的追溯太长,无法在此处添加),但最后几行说:


  File "/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 363, in getpeercert
    'subjectAltName': get_subj_alt_name(x509)

  File "/anaconda3/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 213, in get_subj_alt_name
    ext = cert.extensions.get_extension_for_class(

  File "/anaconda3/lib/python3.6/site-packages/cryptography/utils.py", line 170, in inner
    result = func(instance)

  File "/anaconda3/lib/python3.6/site-packages/cryptography/hazmat/backends/openssl/x509.py", line 127, in extensions
    self._backend, self._x509

  File "/anaconda3/lib/python3.6/site-packages/cryptography/hazmat/backends/openssl/decode_asn1.py", line 252, in parse
    value = handler(backend, ext_data)

  File "/anaconda3/lib/python3.6/site-packages/cryptography/hazmat/backends/openssl/decode_asn1.py", line 438, in _decode_subject_alt_name
    _decode_general_names_extension(backend, ext)

  File "/anaconda3/lib/python3.6/site-packages/cryptography/x509/extensions.py", line 1262, in __init__
    self._general_names = GeneralNames(general_names)

  File "/anaconda3/lib/python3.6/site-packages/cryptography/x509/extensions.py", line 1217, in __init__
    "Every item in the general_names list must be an "

TypeError: Every item in the general_names list must be an object conforming to the GeneralName interface

关于我可能做错了什么的任何想法?

1 个答案:

答案 0 :(得分:0)

我尝试了上面的代码并获得以下输出:

enter image description here