Search code examples
pythonpandasnumpy

Getting AttributeError: partially initialized module 'numpy.core.arrayprint' has no attribute 'array2string' (most likely due to circular import) eror


I tried installing pandarallel but couldn't install due to some errors. Now when I try to simply import pandas and numpy, I am getting error:

import pandas as pd
import numpy as np

AttributeError: partially initialized module 'numpy.core.arrayprint' has no attribute 'array2string' (most likely due to circular import)

I am getting it if I try to import either pandas or numpy. I looked up other answers to similar partially initialied module errors, tried renaming numpy file, but it's still not fixing the issue. I tried upgrading numpy using pip, still it didn't help.

Can someone please help me with this error.


Solution

  • You have installed numpy in your local environment eg. C:/Users/username/AppData/Roaming/Python... which is conflicting with the global installation in C:/Python311/Lib/site-packages/numpy/__init.py__. This conflict is causing Python to load the wrong version or a corrupted version of numpy. To fix this you have to remove/uninstall it from local env and reinstall it with admin previliges to ensure a clean installation, either by using python -m pip install numpy in an admin command prompt or installing it globally.This resolves conflicts and ensures Python uses the correct version of numpy.