简体   繁体   English

Python3无法识别的Python2软件包

[英]Python2 Packages not recoganised by Python3

I have installed both python2.7 and python3.5 in my Ubuntu. 我已经在Ubuntu中安装了python2.7和python3.5。 I mostly use Python3.5 only. 我只使用Python3.5。 I was trying to import some libraries and use them in my program 我试图导入一些库并在程序中使用它们

try:
    import Image
except ImportError:
    from PIL import Image
import pytesseract
n = input()
print(n)
print(pytesseract.image_to_string(Image.open(str(n))))

When I run this code with Python3 filename.py I am getting a package not found error.Then I tried running it with Python filename.py then I am getting the desired output. 当我使用Python3 filename.py运行此代码时,我遇到了未找到包的错误。然后尝试使用Python filename.py运行它,然后得到了所需的输出。 Then I added the input() line and tried to run it and it started throwing an error because input() was introduced only in Python3 然后,我添加了input()行并尝试运行它,并开始引发错误,因为input()仅在Python3引入

Then I tried to locate the pacakages that I have installed namely "PIL(python3-imaging), tesseract, pytesseract" and their location goes something like usr/local/lib/Python/ . 然后,我尝试找到已安装的pacakage,即“ PIL(python3-imaging),tesseract,pytesseract”,它们的位置类似于usr/local/lib/Python/ Since I am new to this packages and stuff my guess is that the erroris caused because they are installed in Python2.7 related files and not in Python3 files. 由于我是这个软件包的新手,我的猜测是该错误是由于它们安装在Python2.7相关文件中,而不是Python3文件中引起的。

How can I solve this problem? 我怎么解决这个问题? Any help would be appreciated. 任何帮助,将不胜感激。

尝试在此行中安装要使用的软件包

python3 -m pip install PIL tesseract pytesseract 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM