Reputation: 3278
I just wanted to try a chunk of code to paste an image on top of another. Well, I cant go much further as an AttributeError
is raised right on the import.
from PIL import Image
# image_path = "/Users/me/images/"
# fg_file = "hello-600x600.jpg"
# bg_file = "deer-1.jpg"
#
# bg = Image.open(image_path + bg_file)
# fg = Image.open(image_path + fg_file)
#
# bg.paste(fg, (10, 10), fg)
# bg.show()
With the import I got the following output:
Traceback (most recent call last):
File "/Users/me/dev/pyExamples/image_manipulation/merge_images.py", line 3, in <module>
from PIL import Image
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 31, in <module>
import logging
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/__init__.py", line 206, in <module>
_lock = threading.RLock()
AttributeError: 'module' object has no attribute 'RLock'
Exception AttributeError: '_shutdown' in <module 'threading' from '/Users/me/dev/pyExamples/threading/__init__.pyc'> ignored
Process finished with exit code 1
I seems to come from the method threading.RLock()
but I don't know what to do here.
Any suggestion?
Upvotes: 3
Views: 465
Reputation: 5960
'/Users/me/dev/pyExamples/threading/__init__.pyc'
This part of the exception suggests that you have a module called threading in your code. The threading module however is part of the standard library and by creating a module called threading, you are practically overriding the standard one. And so PIL is looking for methods and classes that are not there. You will have to rename the threading module in your code to something else and everything should work fine.
Upvotes: 4