AttributeError: Can‘t get attribute ‘_unpickle_block‘

问题:Python 3.6/3.8 运行 pd.read_pickle('xxx.p') 时报错

File ".../.local/lib/python3.8/site-packages/pandas/io/pickle.py", line 187, in read_pickle
    return pc.load(f, encoding=None)
File ".../.local/lib/python3.8/site-packages/pandas/compat/pickle_compat.py", line 249, in load
    return up.load()
File "/usr/lib/python3.8/pickle.py", line 1212, in load
    dispatch[key[0]](self)
File "/usr/lib/python3.8/pickle.py", line 1537, in load_stack_global
    self.append(self.find_class(module, name))
File ".../.local/lib/python3.8/site-packages/pandas/compat/pickle_compat.py", line 189, in find_class
    return super().find_class(module, name)
File "/usr/lib/python3.8/pickle.py", line 1581, in find_class
    return _getattribute(sys.modules[module], name)[0]
File "/usr/lib/python3.8/pickle.py", line 331, in _getattribute
    raise AttributeError("Can't get attribute {!r} on {!r}"
AttributeError: Can't get attribute '_unpickle_block' on <module 'pandas._libs.internals' from '.../.local/lib/python3.8/site-packages/pandas/_libs/internals.cpython-38-x86_64-linux-gnu.so'>

原因:猜测中

第一次出现:由Python3.8 + pandas 1.4.2生成文件在装有Python 3.6 + pandas 1.1.5的电脑上运行时报错。

第二次出现:由Python 3.6 + pandas 1.1.5 生成的文件,在Python 3.8 + pandas 1.1.5 上运行。

解决办法:更新或更改 pandas 的版本

第一次出现:在Python 3.8 上 pip install pandas==1.1.5,然后在Python 3.6 电脑上成功运行。

第二次出现:在Python 3.8 上 用回以前版本 pip3 install pandas==1.4.2

太麻烦了。。但是Python 3.6那个电脑我没有sudo权限。。无法保持Python版本一致。。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
AttributeError: Can't get attribute 'new_block'是一个Python错误,意味着在代码中找不到名为'new_block'的属性。此错误可能由以下几个原因引起: 1. 版本不兼容:这个错误可能是因为您的代码在不同版本的pandas上运行时发生了兼容性问题。引用提到,这个错误在Python 3.8上使用较旧版本的pandas时可能会发生。解决方法是使用兼容的pandas版本,如引用中建议的pip install pandas==1.4.2。 2. 依赖问题:这个错误可能是由于缺少其他必需的依赖项引起的。确保您的环境中安装了所有必需的库,并且版本兼容。 3. 代码错误:这个错误可能是由于您的代码逻辑问题导致的。请检查您的代码中是否正确引用了'new_block'属性,并确保您的代码逻辑正确。 因此,解决AttributeError: Can't get attribute 'new_block'错误的方法包括: - 检查您的代码是否引用了正确的属性。 - 确保您的代码中使用的pandas版本与您的Python版本兼容。 - 确保您的环境中安装了所有必需的依赖项。 如果问题仍然存在,建议提供更多的代码和错误信息以获得更准确的帮助。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [AttributeError: Can‘t get attribute ‘new_block‘ on ‘pandas.core.internals.blocks‘ from ‘C:\\](https://blog.csdn.net/weixin_49076390/article/details/120129317)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [AttributeError: Can‘t get attribute ‘_unpickle_block](https://blog.csdn.net/apple_73036111/article/details/126047452)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值