Home > Net >  inspect.py file in folder makes importing pandas not work anymore
inspect.py file in folder makes importing pandas not work anymore

Time:10-17

I am sorry if this is a silly question but I came across a wierd behaviour. I have a folder with some files, one of them named inspect.py enter image description here

However, if I change the name inspect.py to somethingelse.py, importing pandas starts working. enter image description here

I would really like to understand why this is. I assume it has something to do with the module called inspect which (I THINK??) comes by default installed.

Can anyone help me understand this, please?

CodePudding user response:

Looking a np.ma.core.py I see

import builtins
import inspect
import operator
import warnings
import textwrap
import re

These are all base Python modules. Your local inspect.py gets imported instead, which messes with the importing the rest of np.ma.core, and numpy in turn. And pandas depends on numpy.

  • Related