Post

Python pil

how to install PIL with pip?

Use Pillow which is the “new” or the replacement of PIL, but has the same-named modules to preserve compatibility:

1
pip install pillow

detail:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
λ uv run ./a.py
Traceback (most recent call last):
  File "C:\Users\john\Downloads\d3\a.py", line 5, in <module>
    from PIL import Image
ModuleNotFoundError: No module named 'PIL'
john@SKY-20241029KDE ~/Downloads/d3 (master)
λ uv add PIL
  × No solution found when resolving dependencies:
  ╰─▶ Because there are no versions of pil and your project depends on pil, we can conclude that your
      project's requirements are unsatisfiable.
  help: If you want to add the package regardless of the failed resolution, provide the `--frozen` flag to
        skip locking and syncing.
john@SKY-20241029KDE ~/Downloads/d3 (master)
λ uv add pillow
Resolved 4 packages in 964ms
Prepared 1 package in 3.67s
Installed 1 package in 36ms
 + pillow==11.1.0
--

Comments powered by Disqus.