skip to Main Content

Create an ai virtual environment:

pyton3.11 -m  venv ai

Install module in virtual environment:

cd  ai
python3.11 -m pip install Pillow
python3.11
Python 3.11.0rc2 (main, Jul 21 2023, 09:39:42) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
import Pillow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Pillow'

The Pillow was installed in /home/debian/.local/lib/python3.11/site-packages,why python3.11 -m pip install Pillow can’t install the module Pillow inside ai/lib/python3.11/site-packages?

3

Answers


  1. Chosen as BEST ANSWER

    Enable the virtual environment and import PIL:

    debian@debian:~/ai$ source  bin/activate
    (ai) debian@debian:~/ai$ python3.11 -m pip install Pillow
    Collecting Pillow
      Using cached Pillow-10.0.0-cp311-cp311-manylinux_2_28_x86_64.whl (3.4 MB)
    Installing collected packages: Pillow
    Successfully installed Pillow-10.0.0
    
    [notice] A new release of pip available: 22.2.2 -> 23.2.1
    [notice] To update, run: pip install --upgrade pip
    (ai) debian@debian:~/ai$ python3.11
    Python 3.11.0rc2 (main, Jul 21 2023, 09:39:42) [GCC 10.2.1 20210110] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import  Pillow
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'Pillow'
    >>> import  PIL
    >>> 
    

  2. The import name for Pillow is PIL. Instead of import Pillow, use:

    import PIL
    
    Login or Signup to reply.
  3. It seems that before pip install, you should activate venv ai.
    You just only create venv ai, but it is not activated.

    source ai/bin/activate
    

    It will be needed before pip install.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search