Installing pandas library but could not found in idle shell

hey, I am a beginner in installing external modules i.e. pandas
my IDLE shell is 3.11.3 which is the latest and my Python is also the latest version 3.11. after installing pandas from the cmd prompt but my IDLE shell did not recognize it showing module not found

import pandas
Traceback (most recent call last):
File “<pyshell#1>”, line 1, in
import pandas
ModuleNotFoundError: No module named ‘pandas’

The version of pip you used most likely does not match the version of python you are using.

You can check the version of python that is default like this in a CMD shell.

py

It should says its python 3.11.3

Then you can running pip like this:

py -m pip install pandas
1 Like

My Python version shows 3.12.0. what should I do?
should I upgrade pip

You stated you are using 3.11.3 not 3.12 …

When there is a new release of python you sometimes need to wait for packages to be released that support the new version of python.

You can check on pypi.org. This is the page for pandas pandas · PyPI
You can see that is not a release for 3.12.

I suggest that use python 3.11 in until pandas is released for 3.12.

The py command allows you choose the version of python to use.

py -3.11 -m pip install pandas
1 Like

Pandas can be installed for Python 3.12.
The original problem may also have been caused by having two different Python versions and by not using a Python virtual env. I’m wondering how @k2suraj tried to install pandas and for which Python the install was done.

(I should add that pandas is not yet fully supported for 3.12, according to the pandas issue tracker, but installing it is possible.)

1 Like

The IDLE version is the Python version a particular IDLE comes with. IDLE runs code with the same version of Python that is running IDLE. In particular, imports are done by Python and package-not-found failures are due to a package not being installed in the python running IDLE.

3rd party packages must be installed for each version of python that you want to run the package with. A common beginner problem when having more than one version of Python is installing xyz for one version of Python and then running IDLE with a different version. The failure is the same as if one directly ran the ‘other’ Python version and did the same import. I am thinking about an addition to the IDLE doc to explain this.

Others have pointed to the particulars of this case.

1 Like