import janitor as jn TypeError: 'type' object is not subscriptable

1.1k Views Asked by At

after sucessfully downloading the module

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

TypeError: 'type' object is not subscriptable I am using google colab. I also tried just import janitor instead of import janitor as jn, that also didn't work any help to fix this is greatly appreciated.

2

There are 2 best solutions below

2
Constantin Hong On

I think that's the package's error.

Another person also reported the error that he couldn't import the package.

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

According to the GitHub issue page, They plan to fix it. the current version is 0.24.0

his issue will be fixed at pyjanitor 0.24.1

There are several ways to fix it.

Until the fix is released, use the previous package.

To remove the current pyjanitor in jupyter

!pip uninstall pyjanitor --yes

To install the previous version of the package in jupyter.

!pip install pyjanitor==0.23.1

OR if you are familiar with the library, you may fix the bug with this comment

!pip show pyjanitor

It shows a message like this.

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: [email protected]
License: MIT
Location: /usr/local/lib/python3.8/site-packages
Requires: lazy-loader, multipledispatch, natsort, pandas-flavor, scipy
Required-by: 

In my case, I have to go to Location: /usr/local/lib/python3.8/site-packages and find a directory called janitor

Put a string from __future__ import annotations in these files.

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

OR you can try pyjanitor on python 3.9+.

3
Am1r Safavi On

I also had the same problem (on January 2023) and installing previous version solved my problem.