Pandas version checks

  • [x] I have checked that this issue has not already been reported.

  • [x] I have confirmed this bug exists on the latest version of pandas.

  • [x] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

# Code
import pandas as pd

df = pd.DataFrame({"Name":["Braund"]})

Issue Description

Venv

The venv is owned by root:root with 755 permissions. Pandas version 2.3.1 (but also happens with 2.2.3)

Command

/opt/.venv/bin/python /home/user.name/python_scripts/sketches.py

Traceback Message

Traceback (most recent call last): File "/home/user.name/python_scripts/sketches.py", line 7, in df = pandas.DataFrame( AttributeError: module 'pandas' has no attribute 'DataFrame'

Note: In fact, regardless of the method used, it seems to always output the same error message. I have used to work with other packages in the same environment without any problem. However, if I use root user, then all the scripts I've tried with pandas work as expected.

Expected Behavior

No error message, and creation of a data frame.

Installed Versions

-> Replace this line with the output of pd.show_versions()

Using root privileges,

INSTALLED VERSIONS

commit : c888af6d0bb674932007623c0867e1fbd4bdc2c6 python : 3.10.12 python-bits : 64 OS : Linux OS-release : 5.15.0-142-generic Version : #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8

pandas : 2.3.1 numpy : 1.26.4 pytz : 2025.2 dateutil : 2.9.0.post0 pip : 22.0.2 Cython : None sphinx : 8.1.3 IPython : 8.35.0 adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.13.3 blosc : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2025.3.2 html5lib : None hypothesis : None gcsfs : None jinja2 : 3.1.6 lxml.etree : 5.3.2 matplotlib : 3.10.1 numba : 0.61.2 numexpr : None odfpy : None openpyxl : 3.1.5 pandas_gbq : None psycopg2 : None pymysql : None pyarrow : 19.0.1 pyreadstat : None pytest : 8.3.5 python-calamine : None pyxlsb : None s3fs : None scipy : 1.13.1 sqlalchemy : 2.0.40 tables : None tabulate : None xarray : None xlrd : None xlsxwriter : None zstandard : None tzdata : 2025.2 qtpy : None pyqt5 : None

Comment From: jbrockmendel

This is weird. The pandas import works but not pandas.DataFrame? What do you get from dir(pandas)?

Comment From: mroeschke

Just noting that is very likely not a pandas issue. I would suggest.

  1. Recreate your virtual environment with the packages you need (sharing these steps would be helpful to help diagnose)
  2. Making sure you have no other files named pandas.py that your script is importing