【问题标题】:import janitor as jn TypeError: 'type' object is not subscriptableimport janitor as jn TypeError: \'type\' 对象不可订阅
【发布时间】:2023-02-03 03:55:47
【问题描述】:

模块下载成功后

 !pip install  pyjanitor # works successfully
import janitor as jn # which worked just fine in the past, but suddenly throwing the following TypeError

TypeError: 'type' 对象不可订阅 我正在使用谷歌协作。 我也尝试过只导入看门人而不是将看门人导入为 jn,这也没有用 非常感谢任何解决此问题的帮助。

【问题讨论】:

    标签: python pyjanitor


    【解决方案1】:

    我认为这是包的错误。

    还有一个人也报了无法导入包的错误。

    https://github.com/pyjanitor-devs/pyjanitor/issues/1201

    有几种方法可以修复它。

    如果你熟悉这个库,你可以用this comment修复这个错误

    pip show pyjanitor
    

    它显示了这样的消息。

    Name: pyjanitor
    Version: 0.24.0
    Summary: Tools for cleaning pandas DataFrames
    Home-page: https://github.com/pyjanitor-devs/pyjanitor
    Author: pyjanitor devs
    Author-email: ericmajinglong@gmail.com
    License: MIT
    Location: /usr/local/lib/python3.8/site-packages
    Requires: lazy-loader, multipledispatch, natsort, pandas-flavor, scipy
    Required-by: 
    

    就我而言,我必须去地点:/usr/local/lib/python3.8/site-packages 并找到名为janitor 的目录

    在这些文件中放入一个字符串from __future__ import annotations

    janitor/utils.py
    janitor/functions/conditional_join.py
    janitor/functions/utils.py
    

    或者,在修复发布之前,使用以前的包。

    在 jupyter 中删除当前的 pyjanitor

    !pip uninstall pyjanitor --yes
    

    在 jupyter 中安装以前版本的包。

    !pip install pyjanitor==0.23.1
    

    或者您可以在 python 3.9+ 上尝试pyjanitor

    【讨论】:

    • 首先,我刚刚提交了一个 Pull Request 来解决这个问题
    • 我改变了在Jupiter中卸载包的方式。 @onkaronkar4
    【解决方案2】:

    我也遇到了同样的问题(2023 年 1 月),安装以前的版本解决了我的问题。

    【讨论】:

    • 您的答案可以通过其他支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写出好的答案的信息in the help center
    猜你喜欢
    • 2023-01-15
    • 2022-11-25
    • 1970-01-01
    • 2012-01-10
    • 2018-04-29
    • 2022-12-11
    • 1970-01-01
    • 2023-02-23
    • 2020-09-07
    相关资源
    最近更新 更多