2

How do I open an Image in Python 3.7? I tried:

1.Import Image Image.open("File_name.jpg")

Error received: ImportError: No module named 'Image'

  1. Import cv2 image = cv2.imread('backround.jpg')

Error received: ImportError: No module named 'cv2'

Please let me know of any other ways.

IntelliJ_Please
  • 53
  • 1
  • 2
  • 6
  • Depends on what you're trying to do. [Typical way of opening files](https://stackoverflow.com/a/19508772/3701431) is via `with open('/path/to/image.png') as f:` . If you need to use it with a particular module, then you'll have to edit your question and explain exactly what you're trying to do. – Sergiy Kolodyazhnyy Sep 02 '18 at 23:08
  • Nether the `Image` module, nor `cv2` come with Python by default. You probably need to install the appropriate packages before your imports can work. – Blckknght Sep 02 '18 at 23:11
  • Okay I tried and I didnt get a picture, but I didnt get an error, here is what it did:%run "c:\users\my_user~1\appdata\local\temp\tmpgyzrfx.py" – IntelliJ_Please Sep 02 '18 at 23:15

1 Answers1

5

there are many libraries made for theses cases

so i'll explain pillow

first you need to install it you can use pip : pip install Pillow

or easy install : easy_install Pillow

from PIL import Image
im = Image.open(".../path_of_the_image/name.jpg")
im.show()

for more details you can visit the official documentation here