Home > database >  no module named pil, cant use pip or conda
no module named pil, cant use pip or conda

Time:04-02

Basically it's saying pil doesnt exist. I Googled that, it tells me to install pillow. I tried with pip, with conda, different variations of commands, and nothing worked. Specifically there's a syntax error on install in pip install Pillow.

import PIL
import tkinter as tk

root = tk.Tk()
root.geometry("1920x1080")
play = True
cor1 = PIL.Image.open(r"src\obj\1.jpg")
cor2 = PIL.Image.open(r"src\obj\2.jpg")
cor3 = PIL.Image.open(r"src\obj\3.jpg")
menuop = PIL.Image.open(r"src\obj\menuop.jpg")

def menu():
    global play
    play = False
    menuop.show()
    userchoice = Tkinter.Button()
    button.place(x=1171, y=453, in_=root)
while play == True:
    menu()

Tried: Installing pillow through code, cmd, got a syntax error.
Also tried import image instead, got same error.
Also tried conda install instead of pip install.
Also tried a bunch of variations of the command like --install, ipython, !pip, etc.

In short, can't install pillow, pil doesn't exist, image doesn't exist, can't use pip or conda.

@martineau in the comments linked me a site to download pillow manually, I also tried that. I got the error unable to create process.

List of errors:

pil does not exist

pip **install** syntax error

C:\Users\Asa\AppData\Local\Programs\Python\Python38-32\Scripts>python -m pip install Pillow
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

Fatal error in launcher: Unable to create process using '"c:\users\divit\appdata\local\programs\python\python38-32\python.exe"  "C:\Users\Asa\AppData\Local\Programs\Python\Python38-32\Scripts\pip.exe" install Pillow'

CodePudding user response:

Pip install in your local python folder. Then in the same folder pip install Pillow,tkinter,etc. Dont name your files to something like: "tkinter", "pillow",etc

CodePudding user response:

You don't need to import pip in your script.

Another thing is, after you import PIL, you should use PIL.Image.open(...) (note the PIL. prefix and uppercase I)

Also, another way I often use to try to install is python3 -m pip install Pillow (or python -m pip install Pillow if python3 is not recognized in your system). More install instructions can be consulted through the official Pillow doc

  • Related