Reputation: 3
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?
Upvotes: 0
Views: 17346
Reputation: 43
inside jupyternotebook
, open a file and type
import sys
!{sys.executable} -m pip install PyPDF2
Installing directly PyPDF2
from jupyer notebook rather than anaconda
Upvotes: 0
Reputation: 1
I have also faced the same issue. Note that Python is a case-sensitive language. While using the import command use PyPDF2 and not pyPDF2
To install:
pipenv install PyPDF2
To import:
import PyPDF2
Upvotes: 0
Reputation: 182
It seems that you have not installed PyPDF2 module in your device.
Execute following code in your terminal:
pip install PyPDF2
or
pip3 install PyPDF2
I think this will solve your problem. If this does not solve your problem, then there may be problem in your directory of python.
Upvotes: 0
Reputation: 1994
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
.
Upvotes: 1