Ah yes, I did a test, and I could see an accented path too. Try to see what
it is seeing when it fails. You can catch the exception with IOError:

try:
    img = Image.open(texture)
except IOError:
    print 'cannot open', img

Maybe there are non image files in that directory? You might have to add
more arguments to junk.


On Tue, Mar 3, 2015 at 5:35 PM, francois bonnard <[email protected]>
wrote:

> Nope. I have tried also with a path without accent
>
> Le mardi 3 mars 2015 17:27:55 UTC+1, Chris Lesage a écrit :
>>
>> My first guess would be the accent codes in the name in your path:
>> path = "/Users/francesco/Desktop/*Géosésame*/Maya/sourceimages/
>> selectionMaya"
>>
>> On Tue, Mar 3, 2015 at 5:13 PM, francois bonnard <[email protected]>
>> wrote:
>>
>>> Hey folks
>>>
>>> I am running Maya 2014 os windows 8.1 64 bits.
>>>
>>> I have dowloaded python PIL from this URL
>>> <https://mistermatti.wordpress.com/2014/02/04/maya-2014-with-pythons-pil-module/>
>>>  and
>>> have installed the folder with the files in ...maya2014/python/Lib/site-
>>> packages/
>>>
>>> Here is my script :
>>>
>>> import os
>>> import maya.cmds as cmds
>>> from PIL import Image
>>>
>>> #change the path here
>>> path = "/Users/francesco/Desktop/Géosésame/Maya/sourceimages/
>>> selectionMaya"
>>>
>>>
>>> #list the items in the folder
>>> dir = os.listdir(path)
>>>
>>> junk = [".mayaSwatches", ".DS_Store", ".picasa.ini"]
>>>
>>>
>>> for texture in dir:
>>>     if texture not in junk:
>>>         #Load Image in Pillow
>>>         img = Image.open(texture)
>>>  #create a nurbsPlane for each texture
>>>         mesh = cmds.nurbsPlane(name = texture)
>>>         #create a shader
>>>         shader=cmds.shadingNode("blinn",asShader=True)
>>>         #a file texture node
>>>         name = texture.split(".")[0]
>>>         file_node=cmds.shadingNode("file", name = "file_" + name,
>>> asTexture=True)
>>>         #assign a texture
>>>         cmds.setAttr( "file_" + name +'.fileTextureName', path +'/'+
>>> texture, type="string")
>>>
>>>         # a shading group
>>>         shading_group= cmds.sets(renderable=True,
>>> noSurfaceShader=True,empty=True)
>>>         #connect shader to sg surface shader
>>>         cmds.connectAttr('%s.outColor' %shader ,'%s.surfaceShader'
>>> %shading_group)
>>>         #connect file texture node to shader's color
>>>         cmds.connectAttr('%s.outColor' %file_node, '%s.color' %shader)
>>>         cmds.select(mesh)
>>>         cmds.hyperShade( assign=shader)
>>>
>>> Here is the issue :
>>>
>>> # Error: line 1: IOError: file C:\Program Files\Autodesk\Maya2014\
>>> Python\lib\site-packages\PIL\Image.py line 1952: 2 #
>>>
>>> Obviously the issue is on this line :
>>>
>>> img = Image.open(texture)
>>>
>>> What Do I miss ?
>>>
>>> Thanls for the help
>>>
>>> Fransua
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Python Programming for Autodesk Maya" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/python_inside_maya/a7e7c289-b5e4-4fd1-a7c2-
>>> c20b511b074d%40googlegroups.com
>>> <https://groups.google.com/d/msgid/python_inside_maya/a7e7c289-b5e4-4fd1-a7c2-c20b511b074d%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/bf7994c5-8580-4f35-86f9-d2d582527bff%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/bf7994c5-8580-4f35-86f9-d2d582527bff%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAHUba0JGw7gUVLGBcEw5T%3DCEuTioPg0%3D1Y1vK1cH8TSyzRoTxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to