# Probelms with Pillow: from PIL import image // modulenotfounderror no module named 'PIL'

**URL:** <https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040>\
**Category:** Python Help\
**Tags:** help\
**Created:** [March 21, 2023, 12:55pm UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040 "2023-03-21T12:55:22Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidsss](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@davidsss](https://discuss.python.org/u/davidsss)\
**Post date:** [March 21, 2023, 12:55pm UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/1 "2023-03-21T12:55:22Z")

</div>

Hello,  
I am creating a script that organizes PNG files into a single picture.

However upon this line:

> from PIL import Image

I get the following error:

> from PIL import Image  
> ModuleNotFoundError: No module named ‘PIL’

I have newly installed PyCharm and Python 3.11.2 and installed pillow 9.4.0. Both seem to be correctly installed as when i ask to show the location or version of both in the Terminal i get correct answers. However it cannot get it to regognize PIL and import the Image function!

Does anyone know how to circumvent this?  
Kind regards

---

<div class="post-metadata">

**Author:** ![tjreedy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tjreedy/32/137_2.png) [@tjreedy](https://discuss.python.org/u/tjreedy)\
**Post date:** [March 21, 2023, 3:06pm UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/2 "2023-03-21T15:06:23Z")

</div>

If you have other pythons on your system (which is?) then you likely installed pillow to some other python. What command did you use to install?

---

<div class="post-metadata">

**Author:** ![davidsss](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@davidsss](https://discuss.python.org/u/davidsss)\
**Post date:** [March 21, 2023, 3:20pm UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/3 "2023-03-21T15:20:55Z")

</div>

Hey Terry,  
I used `“pip install pillow” in the terminal of Pycharm. I use Windows 11 and have never worked with python before therefore i dont think i should any other pythons on my machine.

---

<div class="post-metadata">

**Author:** ![tjreedy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tjreedy/32/137_2.png) [@tjreedy](https://discuss.python.org/u/tjreedy)\
**Post date:** [March 21, 2023, 3:25pm UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/4 "2023-03-21T15:25:24Z")

</div>

I don’t use pycharm and cannot answer further.

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [March 21, 2023, 3:43pm UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/5 "2023-03-21T15:43:10Z")

</div>

I’m not familiar with it either, but its possible Pycharm has automatically created a virtual environment for you.

> [@davidsss](#):
>
> Both seem to be correctly installed as when i ask to show the location or version of both in the Terminal i get correct answers.

Please actually show us what these answers are. Specifically, in the system terminal in which you ran `python -m pip install pillow` (make sure you run `python -m pip`, in case `pip` maps to a different `python`), please provide the output of `where python` and `python -c "import sys; print(sys.executable)"`, and in the same Python interpreter in which you attempted to `import PIL`, likewise show the output of `import sys; print(sys.executable)`.

If these don’t match, then there’s your problem. Otherwise, something weird is going on, which we can try to investigate further.

---

<div class="post-metadata">

**Author:** ![davidsss](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@davidsss](https://discuss.python.org/u/davidsss)\
**Post date:** [March 27, 2023, 7:45am UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/6 "2023-03-27T07:45:17Z")

</div>

Thank you for the quick response! I have tried your tipps, but to no avail, I still get the module not found error. Attached are screenshots of what i attemted. As stated before both pillow an python seem to be installed and know where they are but when asked python cant import from PIL.

I hope this gives a clearer image of the problem.

Regards,

 ![Screenshot 2023-03-27 093211](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/4/45a0f403bad7dbd06820e11ad09ee1748b36ef6b.png)

---

<div class="post-metadata">

**Author:** ![davidsss](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@davidsss](https://discuss.python.org/u/davidsss)\
**Post date:** [March 27, 2023, 7:45am UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/7 "2023-03-27T07:45:55Z")

</div>

![Screenshot 2023-03-27 093002](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/6/64e2e7d38d2a8412b09fea47d7519c8656025b3c.png)

---

<div class="post-metadata">

**Author:** ![davidsss](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@davidsss](https://discuss.python.org/u/davidsss)\
**Post date:** [March 27, 2023, 7:46am UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/8 "2023-03-27T07:46:39Z")

</div>

![Screenshot 2023-03-27 093439](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/6/6c4ba6fda32fd6f1f7d602c92e77f4753f253e95.png)

---

<div class="post-metadata">

**Author:** ![davidsss](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@davidsss](https://discuss.python.org/u/davidsss)\
**Post date:** [March 27, 2023, 7:50am UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/9 "2023-03-27T07:50:29Z")

</div>

![Screenshot 2023-03-27 093618](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/9/994b981ac937bc35780a039ad625b606e6519e79.png)

---

<div class="post-metadata">

**Author:** ![davidsss](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@davidsss](https://discuss.python.org/u/davidsss)\
**Post date:** [March 27, 2023, 7:51am UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/10 "2023-03-27T07:51:22Z")

</div>

![Screenshot 2023-03-27 093833](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/2/20281b619bb74c2d8cefaec731ad618ac440d837.png)

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [March 27, 2023, 8:33am UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/11 "2023-03-27T08:33:42Z")

</div>

As can be seen in each of the `pip show`, `where python` and `sys.executable` output, you’ve installed Pillow in your base Python install located at `C:\Users\d.schlue\AppData\Local\Programs\Python\Python311`, but PyCharm is running your code inside the [virtual environment](https://docs.python.org/3/tutorial/venv.html) located at `C:\Users\d.schlue\PycharmProjects\pythonProject1\venv`.

Virtual environments each have their own independent sets of Python package isolated from both each other and (by default) their base Python install, and are a recommended way of managing your dependencies to avoid packages installed for one project interfering, conflicting or being incompatible with those used for another, among other reasons. Pycharm likely instantiated and activated one for you when you created your project `pythonProject1`, and thus any packages you’ve installed in your base Python will not be importable with this virtual environment activated, and vice versa.

Therefore, you need to install `Pillow` into the virtual environment Pycharm has created for you. I don’t use Pycharm, but I did some googling and it seems Pycharm [has a GUI for that](https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html#interpreter-settings), or you can run your pip install commands in the [Pycharm Terminal](https://www.jetbrains.com/help/pycharm/terminal-emulator.html). Or, you could manually activate the env Pycharm created in your system terminal and then install, or just run `C:\Users\d.schlue\PycharmProjects\pythonProject1\venv\Scripts\python.exe -m pip install pillow` directly (where that’s the path to the venv Python that Pycharm shows you in its console output).

You should presumably record this requirement somewhere more permanent so that you or others can install your project, such as under `project.dependencies` in your `pyproject.toml`, in a `requirements.txt` file, or elsewhere depending on what packaging/environment management tool(s) you’re using. However, it seems you may not have gotten to that point, so you don’t necessarily have to worry about that now—just keep in mind you’ll want to do that at some point if you want to share or re-use your code.

> [@davidsss](#):
>
> I have tried your tipps, but to no avail, I still get the module not found error.

Just to note, as mentioned the commands I gave you weren’t to fix the problem, but rather to provide the information required to diagnose what’s actually going on a and recommend a fix.

Also, for the future, [please don’t paste images of textual errors/exceptions/terminal output](http://idownvotedbecau.se/imageofanexception/), [for many reasons](https://meta.stackoverflow.com/a/285557). Instead, paste it as text within a code fenced block, using either the \</\> button in the toolbar, or via typing triple backticks above and below the code in question, like this:

````markdown
```
<YOUR FULL OUTPUT HERE>
```

````

Best of luck!

---

<div class="post-metadata">

**Author:** ![davidsss](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@davidsss](https://discuss.python.org/u/davidsss)\
**Post date:** [March 27, 2023, 8:44am UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/12 "2023-03-27T08:44:32Z")

</div>

Thank you so much for the fast and detailed reply! I could install Pillow through the GUI that you made me aware of and (besides some new errors that are a different topic for now :D) Pillow is found and working as intended.  
Thank you again,  
I wish you a pleasant start into the week

---

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [March 27, 2023, 8:48am UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/13 "2023-03-27T08:48:25Z")

</div>

[Please don’t post screenshots of text such as error messages](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors/285557#285557).

The most likely issue is that you have two versions of Python installed, one has Pillow installed and the other doesn’t.

Please run this code and tell us what it does. Copy and paste the output and [format it as code](https://discuss.python.org/t/python-discourse-quick-start/116#how-do-i-post-code-snippets-error-messages-etc-4):

```auto
python -c "import sys; print(sys.version, sys.executable); import PIL"

```

Please run that from both PyCharm and the Windows command prompt, and compare the results.

This post may also help:

> <https://stackoverflow.com/questions/8863917/importerror-no-module-named-pil>

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [March 27, 2023, 8:54am UTC](https://discuss.python.org/t/probelms-with-pillow-from-pil-import-image-modulenotfounderror-no-module-named-pil/25040/14 "2023-03-27T08:54:59Z")

</div>

FYI, I assume it didn’t send you the emails (yet)—the user already confirmed the problem was solved after I asked them similar questions, analyzed the results and explained the situation and what they should do (albeit it turned out to be, as I suspected, that Pycharm had automatically created a venv for the user rather than two separate Python installs).
