"no module named PyPDF2" error "no module named PyPDF2" error python python

"no module named PyPDF2" error


In my case, I was trying to import 'pyPdf2' instead of 'PyPDF2'. Observe the case.

import PyPDF2

is correct.


If you use python3 maybe

apt-get install python3-pypdf2


I faced the same problem. But, In my case,

  • I previously installed Python3 separately from official website and was using without any issues

  • Then later I installed Anaconda package distribution software which itself has another Python3 installed in corresponding directory.

So, when I installed PyPDF2, it installed normally and while importing throws an error, because the base path of python3 was changed to be used with Anaconda.

Then I opened Anaconda prompt and installed PyPDF2 there and tried to import. It worked!!

Then I can use it from any command prompt in my Windows PC. Or else you can delete Anaconda and everything works normally. Its just a conflict of two pythons in my pc.

Conclusion: Try any overlapping softwares in your PC(in my case Anaconda prompt) and try their CMD to install packages and import. If I wanted to install any package I have to go to Anaconda prompt and install it and importing that modules works anywhere without any error. So from now on wards I'm only using Anaconda prompt as my default installation prompt.