Pillow / PIP not working in maya

Pillow / PIP not working in maya

Craig_Lamorte
Advocate Advocate
9,164 Views
22 Replies
Message 1 of 23

Pillow / PIP not working in maya

Craig_Lamorte
Advocate
Advocate

Hello,

 

I have done a pip install pillow already.  PIL resides in my python site-packages.  I can even run it just fine inside my text editor.  However when I add my code into a tool that is launched in maya 2017, i get an error "No Module named PIL"

 

I am doing -

from PIL import Image

 

Why does it not work inside of maya??

 

Thanks

Craig

0 Likes
Accepted solutions (1)
9,165 Views
22 Replies
Replies (22)
Message 2 of 23

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution

Hi,

 

Maya uses a custom build python(VS2012). I've written a blog for how to build pillow for Maya 2017. Please check it out.

 

Yours,

Li

Message 3 of 23

Craig_Lamorte
Advocate
Advocate

Is there any way to download the rebuilt pillow? without having to go through that process?  I do not have access to VS2012 so I can not do that process.

0 Likes
Message 4 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

I do have my built for Maya 2017 stored on my personal google drive, here is link:

 

https://drive.google.com/drive/folders/0B5n3XnEYY_bVN1d5QWFiSUhGMG8?usp=sharing

 

Extract pillow.zip into Maya2017/Python and copy openjp2 into pil directory. For Maya 2018, you'll need to build with VS2015.

 

BTW: You can use VS2012/VS2015 Community version to build them.Microsoft provides them for free.

 

Yours,

Li

0 Likes
Message 5 of 23

Craig_Lamorte
Advocate
Advocate

Thank you so much!!! it works!!

0 Likes
Message 6 of 23

Anonymous
Not applicable

Thank you so much!

0 Likes
Message 7 of 23

328665042
Contributor
Contributor

Hello, Li Chengxi:

I've read your blog. I want to try to build the one for maya2018 and 3dmax 2018 by myself, but I fail to build at first step.

I first install vs2015 and Windows SDK 8.1 as you said, and I run VS2015 x64 Native Tools Command Prompt(VS2015 X64 本机工具命令提示符 ) as Administrator.

And I stuck into the setting enviroment variables step.

my Maya2018 installation path is C:\Program Files\Autodesk\Maya2018, 

and my 3dmax2018 path is C:\Program Files\Autodesk\3Ds Max 2018

I write the following code in command prompt :

 

Path=%path%;"C:\Program Files\Autodesk\Maya2018\bin"
Python="C:\Program Files\Autodesk\Maya2018\bin"

 

The second line get a error:

 

Python: can't open file '=C:\Program Files\Autodesk\Maya2018\bin': [Errno 22] Invalid argument

 

I don't know how to fix it, can you help me?

Here is the screenshot of the error.

error.png

Thank you very much.

Yixiong Xu

2019.05.30

0 Likes
Message 8 of 23

cheng_xi_li
Autodesk Support
Autodesk Support
Hi,

I think you should remove the quotes for the python settings. I remembered I had the same issue when I wrote this blog.

Yours,
Li
0 Likes
Message 9 of 23

328665042
Contributor
Contributor

Hi Li Chengxi,

Thank you for your quick reply.

I try your tip but it seems not work on my machine.

I remove it from both lines and I still get an error.

Here is my code:

Path=%path%;C:\Program Files\Autodesk\Maya2018\bin
Python=C:\Program Files\Autodesk\Maya2018\bin

Here is the error screenshot.

error.png

I'm a rookie in building python packages and I don't know how to do it.

Can you help me?

Thank you very much.

Yixiong Xu

2019.05.30

0 Likes
Message 10 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Setting environment variables should be using set command,

 

e.g.

set Path=%path%;Maya2017/bin
set Python=Maya2017/bin

Please use / instead of \ on windows platform.

 

Yours,

Li

0 Likes
Message 11 of 23

328665042
Contributor
Contributor

Hi, Li:

Thank you very much. It works without any error!!!

I'm going to the next difficult steps

Yixiong Xu

2019.05.30

0 Likes
Message 12 of 23

Craig_Lamorte
Advocate
Advocate

Hello,

 

Going to be upgrading tools to maya 2020, and of course PIL still doesn't work.  And using PIL built in VS2012 also causes maya to crash.  I am guessing that for maya 2020 we need PIL built in a different version of visual studio?

0 Likes
Message 13 of 23

Anonymous
Not applicable

Are you referring to the tools in the google drive? If I were to use the google drive files with Maya 2020 wold Pillow work?

0 Likes
Message 14 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Yes, for Maya 2020 you'll need VS2017. It should be always the same as the requirement of the C++ developer environment.

 

Yours,

Li

0 Likes
Message 15 of 23

Craig_Lamorte
Advocate
Advocate

Ok thanks.  I don't suppose there is already a Pillow package out there rebuilt with VS2017 that i can download?  The instructions you wrote up for maya 2017/2018 and rebuilding it in VS2012 were a bit hard for me to follow.  

Message 16 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

Hi Craig,

 

No, there isn't. I could try to build it next week.

 

Yours,

Li

Message 17 of 23

cheng_xi_li
Autodesk Support
Autodesk Support

So, I've built one today.

 

There are some small issues. I am not sure why Pillow reported that it has tiff and openjpeg2 feature enabled after building but missing when I was running selfTest.

 

However, it seems that TIFF still works, so it shouldn't be a big problem.

 

Here is the link: https://drive.google.com/open?id=1aGCgPrAymmMuOxhYCCj75E34vLIYfNAS

 

Yours,

Li

0 Likes
Message 18 of 23

Craig_Lamorte
Advocate
Advocate

Thank you so much!!

0 Likes
Message 19 of 23

328665042
Contributor
Contributor

Hello,

I recently restart building the Pillow Package for Maya2018 with VS2015.

In my opinion, I successfully build the Mandatory libraries(Zlib and JPEGsr9b) for Pillow 5.1.

As your suggest, I modify the setup.py file of Pillow with the correct library path.

截图20200628110528.png

 

But the build failed at the last step, the Pillow building always failed.

截图20200628110303.png

 

I don't know how to fix the problem, can you give me some suggestion?

BTW, I don't know how to build the Pillow with DEBUG mode on, can you show me some code for enabling DEBUG building?

Thank you very much!

Looking forward to your reply.

Yixiong Xu

2020.06.28

0 Likes
Message 20 of 23

328665042
Contributor
Contributor

Hello, 

After some tests, I successfully compile the Pillow 5.1 package(Minimum require) with VS2015.

I made a mistake when I compile the jpeg9b/9c lib.

For building the jpeg9b/9c, you need to NEW... a configuration for x64 platform, the original solution platform is Win32 which is not suitable for the Pillow build.

Building the Pillow package is really difficult for a newbie like me.

Anyway, thank you very much for your tutorial! 

Yixiong Xu

2020.06.28