-
I am trying to make an Instagram bot for some coding practice and every time I run the code it says that I do not have PIL installed. I do have PIL installed, and it is located in the correct PATH for my Python to find it. What is the issue? Heres the code: from instagrapi import Client
username = "****"
password = "****"
client = Client()
client.login(username, password)
and the return is:
Traceback (most recent call last):
File "C:\Users\climb\AppData\Local\Programs\Python\Python310\lib\site-packages\instagrapi\mixins\clip.py", line 16, in <module>
from PIL import Image
File "C:\Users\climb\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\Image.py", line 82, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (C:\Users\climb\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/climb/AppData/Local/Programs/Python/Python310/Code/Bruno.Fuenty Instagram Bot.py", line 1, in <module>
from instagrapi import Client
File "C:\Users\climb\AppData\Local\Programs\Python\Python310\lib\site-packages\instagrapi\__init__.py", line 12, in <module>
from instagrapi.mixins.clip import DownloadClipMixin, UploadClipMixin
File "C:\Users\climb\AppData\Local\Programs\Python\Python310\lib\site-packages\instagrapi\mixins\clip.py", line 18, in <module>
raise Exception("You don't have PIL installed. Please install PIL or Pillow>=8.1.1")
Exception: You don't have PIL installed. Please install PIL or Pillow>=8.1.1 Is there anyone that understands that error message and why it isn't recognizing PIL? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 19 replies
-
Maybe you've installed Pillow using a different Python interpreter. See https://snarky.ca/why-you-should-use-python-m-pip/ How did you install Pillow? What do you get for: python --version --version
python -m PIL |
Beta Was this translation helpful? Give feedback.
-
Depending on how you define things, Pillow is installed, just not correctly. There is an error when instagrapi tries to import it - I would look at the ImportError and think that you are missing the C parts of Pillow - have you tried uninstalling Pillow and re-installing it? |
Beta Was this translation helpful? Give feedback.
To me, the fact that you are moving packages around manually means you are missing the simplicity of virtual environments.
If you look at https://realpython.com/python-virtual-environments-a-primer/ or https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/, you will learn about
venv
, and that once you have activated a virtual environment, you can usepip
to install packages into them without the manual rearranging that you're currently doing.