TheWhaleOnPluto
TheWhaleOnPluto

Reputation: 51

How to run Python libraries PIL and pillow in the Unreal Editor

I am currently attempting to run a Python file inside of the Unreal Editor's scripting environment that imports and uses the pillow (PIL fork) library's Image module:

from PIL import Image

However in the Unreal Editor's log I am getting the below error message when I try to run this script:

LogPython: Error: ModuleNotFoundError: No module named 'PIL'

I already have pillow installed on my computer, however the Unreal Editor doesn't seem to have it installed in it's internal Python package.

Is there any way I can execute or install pillow into the Unreal Editor?

Upvotes: 1

Views: 1103

Answers (2)

aentsix
aentsix

Reputation: 1

What fixed it for me is going to (Edit > Project Settings > Search Python) and then adding an (Additional Path) entry and pasting the location: "User/AppData/Roaming/Python/Python*/site-packages" or wherever your site-packages are installed.

After that I just restarted and UE recognized all libraries.

Upvotes: 0

Greymanic
Greymanic

Reputation: 136

I would be curious to see others approaches but I've found that adding Pythons site-packages path to the PYTHONPATH at Unreal Startup to be the ideal approach.

In the Unreal Python Settings (Edit > Project Settings > Search Python) you have the option to add a script that executes at start up. It's here we append any paths needed in our Pipeline.

import sys

if __name == '__main__':
   sys.path.append("C:\\python37\\Lib\\site-packages")

Assuming you have PIL, or PySide2 or any other library pip installed then it should become available.

Upvotes: 2

Related Questions