首页 > 解决方案 > 使用 Python quandl.get 获取 TypeError:raise_on_status

问题描述

我正在关注关于 ML 和 quandl 的教程,并为 python3 导入了 quandl 和依赖项。当我跑

import quandl

data = quandl.get("EIA/PET_RWTC_D")
print(data.head())

我有一个 quandl 帐户,此代码来自 quandl python 文档,因为我想确保教程没有错(https://www.youtube.com/watch?v=JcI5Vnw0b2c&list=PLQVvvaa0QuDfKTOs3Keq_kaG2P55YRn5v&index=2)(我确定它是小写的 quandl 用于导入,因为它因视频的发布日期而不同),我也尝试使用我的 api_key 并在 quandl.get() 中使用该 arg

我得到错误:

Traceback (most recent call last):
File "ml_regression1.py", line 4, in <module>
quandl.get("EIA/PET_RWTC_D", authtoken="MyAuthTokenPlaceHolder")
File "/usr/local/lib/python3.5/dist-packages/quandl/get.py", line 48, in get
   data = Dataset(dataset_args['code']).data(params=kwargs, handle_column_not_found=True)
File "/usr/local/lib/python3.5/dist-packages/quandl/model/dataset.py", line 47, in data
    return Data.all(**updated_options)
File "/usr/local/lib/python3.5/dist-packages/quandl/operations/list.py", line 14, in all
    r = Connection.request('get', path, **options)
File "/usr/local/lib/python3.5/dist-packages/quandl/connection.py", line 38, in request
    return cls.execute_request(http_verb, abs_url, **options)
File "/usr/local/lib/python3.5/dist-packages/quandl/connection.py", line 42, in execute_request
    session = cls.get_session()
File "/usr/local/lib/python3.5/dist-packages/quandl/connection.py", line 58, in get_session
    adapter = HTTPAdapter(max_retries=cls.get_retries())
File "/usr/local/lib/python3.5/dist-packages/quandl/connection.py", line 74, in get_retries
    raise_on_status=False)
TypeError: __init__() got an unexpected keyword argument 'raise_on_status'

任何帮助都会很棒,谢谢。

标签: pythonpython-3.xtypeerrorquandl

解决方案


pip3 install --upgrade urllib3为我解决了这个问题(urllib3 不是最新的)。

另请参阅https://stackoverflow.com/a/53375266/8496767


推荐阅读