Issue
I am attempting to Import PyPDF2 in order to read a PDF file and parse through it. I am using a Raspberry Pi, and have installed PyPDF2 using the command pip install PyPDF2
. However, when I try importing it, I am getting ModuleNotFoundError.
I think it may have installed it into the wrong location. When I do python -V it says I am using version 2.7.16. But the error states it's trying to look into the python3 folder?
I am attempting to import it using the line import PyPDF2
The error I'm getting is:
Traceback (most recent call last):
File "/home/pi/SqlDatabase.py", line 5, in <module>
import PyPDF2
File "/usr/lib/python3/dist-packages/thonny/backend.py", line 305, in _custom_import
module = self._original_import(*args, **kw)
ModuleNotFoundError: No module named 'PyPDF2'
Any idea of how I can install PyPDF into the correct directory, or perhaps a different solution?
Solution
If you are starting the program with python3 (e.g. see if the first line of the file has #!/usr/bin/python3
or similar), you need to install the library with pip3
.
Answered By - Ivan Voras Answer Checked By - David Marino (WPSolving Volunteer)