简体   繁体   中英

Python2 Packages not recoganised by Python3

I have installed both python2.7 and python3.5 in my Ubuntu. I mostly use Python3.5 only. 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. Then I added the input() line and tried to run it and it started throwing an error because input() was introduced only in 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/ . 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.

How can I solve this problem? Any help would be appreciated.

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

python3 -m pip install PIL tesseract pytesseract 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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