我在我的Ubuntu中安装了python2.7和python3.5。我只使用Python3.5。我试图导入一些库并在我的程序中使用它们。
try:
import Image
except ImportError:
from PIL import Image
import pytesseract
n = input()
print(n)
print(pytesseract.image_to_string(Image.open(str(n))))当我使用Python3 filename.py运行这段代码时,我得到的包没有找到error.Then,我尝试使用Python filename.py运行它,然后得到所需的输出。然后我添加了input()行并尝试运行它,它开始抛出一个错误,因为input()只在Python3中引入。
然后我试着定位我安装的"PIL(python3-imaging),tesseract,pytesseract“,它们的位置类似于usr/local/lib/Python/。由于我是这个包的新手,所以我猜测错误是因为它们安装在Python2.7相关文件中,而不是在Python3文件中。
我该如何解决这个问题?任何帮助都将不胜感激。
发布于 2017-03-19 14:54:49
尝试使用这一行来安装要使用的包。
python3 -m pip install PIL tesseract pytesseract https://stackoverflow.com/questions/42887922
复制相似问题