python icon indicating copy to clipboard operation
python copied to clipboard

Package name uppercase problem with windows image

Open mathieugouin opened this issue 7 months ago • 2 comments

Overview

I found a strange pip problem on windows based image related to python packages that are installed with capital letters in their folder name.

The problem is happening when uninstalling a package with uppercase letters in its name, eg: PyPDF2.

I confirm Linux images don't have this problem.

How to reproduce

Here are minimal reproducible steps:

docker pull python:3.13.3-windowsservercore-ltsc2022
docker run --rm -it python:3.13.3-windowsservercore-ltsc2022 powershell

# First install
pip install PyPDF2
python -c "import PyPDF2 as p; print(p.__file__)"

# Prints:
C:\Python\Lib\site-packages\PyPDF2\__init__.py

pip uninstall -y PyPDF2

# 2nd install
pip install PyPDF2
python -c "import PyPDF2 as p; print(p.__file__)"

# Prints:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
    import PyPDF2 as p; print(p.__file__)
    ^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'PyPDF2'

# Let's try lowercase:

python -c "import pypdf2 as p; print(p.__file__)"

# Prints:

C:\Python\Lib\site-packages\pypdf2\__init__.py

# Even if:
pip freeze

# Prints:
PyPDF2==3.0.1

mathieugouin avatar Jun 02 '25 19:06 mathieugouin

I have successfully reproduced, but unfortunately I can't see any way for this to be an issue with the image. There's probably a few interrelated issues here in both Python and PIP (case insensitive filesystem handling, etc), but given https://peps.python.org/pep-0008/ and the fact that PyPDF2 is officially deprecated in favor of pypdf (in part because of the capitalized naming), I doubt there's going to be much (if any) upstream interest in digging in more. 🙈

tianon avatar Jun 02 '25 22:06 tianon

Just to add that I also have the problem with pillow (PIL vs pil) also.

Should I post to pip? Even though it only exhibits this behavior inside a container?

mathieugouin avatar Jun 02 '25 23:06 mathieugouin