1

I have been trying many solutions: but I cannot import PyPDF2 yet.

I got the following error. I have already check if the version is right and it says it is already satisfied. I changed the computer twice and used Jupyter notebook and Pycharm alternatively. I am not sure what is wrong. I can import other moduels.

Command Line error
C:\Users\taye>python3.11 -m pip install PyPDF2
Requirement already satisfied: PyPDF2 in c:\users\taye\appdata\local\packages\pythonsoftwarefoundation.python.3.11_qbz5n2kfra8p0\localcache\local-packages\python311\site-packages (3.0.1)
---------------------------------------------------------------------------
**ERROR MESSAGE
**
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[2], line 1
----> 1 import PyPDF2

ModuleNotFoundError: No module named 'PyPDF2'
Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
Thet
  • 11
  • 3
  • 1
    It's quite likely that your Jupyter installation is using a different Python from your command line. you need to install this package through Jupter. – Tim Roberts Jul 06 '23 at 21:49

1 Answers1

0

it's possible that your notebook and your PyPDF2 library are in 2 different Python environments.

Quick and easy solution:

Use the !pip install PyPDF2 command to install it in the Jupyter Notebook environment

Read this link for other (maybe better) solution here:

https://stackoverflow.com/a/39022003/12451082

https://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/