Reputation: 729
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.
Upvotes: 0
Views: 81
Reputation: 376
try this line to install the package you want to use
python3 -m pip install PIL tesseract pytesseract
Upvotes: 1