我目前正致力于图像识别程序 使用: python 3.5 PyCharm Community Edition 2016.3作为IDE 我使用 pip install Pillow
安装了Pillow 3.1.2我的代码是:
from PIL import Image
im = Image.open('images/dot.png')
im.load()
在运行时显示错误
Traceback (most recent call last):
File "/home/harry/PycharmProjects/python study/image.py", line 1, in <module>
from PIL import Image
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 31, in <module>
import logging
File "/usr/lib/python3.5/logging/__init__.py", line 28, in <module>
from string import Template
ImportError: cannot import name 'Template'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module>
from urllib.request import urlopen
File "/usr/lib/python3.5/urllib/request.py", line 88, in <module>
import http.client
File "/usr/lib/python3.5/http/client.py", line 71, in <module>
import email.parser
File "/usr/lib/python3.5/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/usr/lib/python3.5/email/feedparser.py", line 27, in <module>
from email import message
File "/usr/lib/python3.5/email/message.py", line 16, in <module>
from email import utils
File "/usr/lib/python3.5/email/utils.py", line 40, in <module>
from email.charset import Charset
File "/usr/lib/python3.5/email/charset.py", line 15, in <module>
import email.quoprimime
File "/usr/lib/python3.5/email/quoprimime.py", line 44, in <module>
from string import ascii_letters, digits, hexdigits
ImportError: cannot import name 'ascii_letters'
Original exception was:
Traceback (most recent call last):
File "/home/harry/PycharmProjects/python study/image.py", line 1, in <module>
from PIL import Image
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 31, in <module>
import logging
File "/usr/lib/python3.5/logging/__init__.py", line 28, in <module>
from string import Template
ImportError: cannot import name 'Template'
*
任何人都可以帮助解决这个问题
答案 0 :(得分:0)
当前工作目录中有一个名为“string.py”的文件。 您不应将文件命名为与Python标准库或保留字中的模块相同。