반응형
Python 2.7 용 실행 파일을 사용하여 PIL 1.1.7을 설치했습니다. 하지만이 코드를 실행할 때 :
import requests
from PIL import *
def main() :
target = "http://target/image.php" #returns binary data for a PNG.
cookies = {"mycookie1", "mycookie2"}
r = requests.get(target, cookies=cookies)
im = Image.open(r.content) #r.content contains binary data for the PNG.
print im
if __name__ == "__main__" :
main()
오류가 발생합니다.
Traceback (most recent call last):
File "D:\Programming\Python\code\eg_cc1.py", line 17, in <module>
main()
File "D:\Programming\Python\code\eg_cc1.py", line 13, in main
im = Image.open(r.content)
NameError: global name 'Image' is not defined
Lib \ site-packages
에 PIL을 설치했습니다.
해결 방법
이미지 모듈을 명시 적으로 가져와야합니다.
>>> from PIL import *
>>> Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'Image' is not defined
>>> import PIL.Image
>>> Image
<module 'Image' from 'c:\Python27\lib\site-packages\PIL\Image.pyc'>
>>>
아니면 그냥
>>> import Image
참조 페이지 https://stackoverflow.com/questions/20443846
반응형
'파이썬' 카테고리의 다른 글
파이썬 +에 대해 지원되지 않는 피연산자 유형 : 'int'및 'str' (0) | 2020.12.27 |
---|---|
파이썬 pandas.Series에 항목을 추가 하시겠습니까? (0) | 2020.12.27 |
파이썬 How to use 2to3 properly for python? (0) | 2020.12.27 |
파이썬은 튜플을 배열로 변환 (0) | 2020.12.27 |
파이썬 Square of each element of a column in pandas (0) | 2020.12.27 |
댓글