"no module named PyPDF2" error

89,383

Solution 1

If you use python3 maybe

apt-get install python3-pypdf2

Solution 2

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

import PyPDF2

is correct.

Solution 3

This is the case which I followed for python3. For python2 try with pip:

pip install PyPDF2

Solution 4

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.

Solution 5

I had this problem too when I tried to import PyPDF2 like this:

sudo apt-get install python-pypdf2

When running some simple script with import PyPDF2, I would get an error like this:

ImportError: No module named PyPDF2

The solution was to also install pdfmerge, like this:

pip install pdfmerge

Share:
89,383

Related videos on Youtube

ALisboa
Author by

ALisboa

Do-gooder interested in anything I don't already know. I love coding because it's beautiful and it can be a powerful force for good. My world view: intelligence and good character are linked the future is good if you make it so labels are not for people what you know is your most important asset Love: nerd jokes, Jeopardy, puzzles, languages, dancing Love not: how academia, computer science or any kind of thinking professional gets portrayed in the media, we are actually very cool Cliche-crusher: don't like chess (at all)

Updated on March 17, 2022

Comments

  • ALisboa
    ALisboa over 2 years

    I use Spyder, with Python 2.7, on a windows 10. I was able to install the PyPDF2 package with a conda command from my prompt. I said installation complete. Yet, If I try to run a simple import command:

    import PyPDF2

    I get the error:

    ImportError: No module named PyPDF2

    How can I fix this?

    • Jithin
      Jithin almost 8 years
      have you tried with pip ? Like pip install PyPDF2
  • Tejas Tank
    Tejas Tank over 6 years
    Yes. python 3 matters for pypdf2.
  • noiivice
    noiivice almost 6 years
    Funny enough this simple fix worked for me. I was importing pyPDF2 and the upper case mattered.
  • Kamil Naja
    Kamil Naja over 4 years
    Works very well
  • Prasanna
    Prasanna almost 4 years
    I also had the same issue, this does solve my problem. but I need to install PyPDF2 with this command conda install -c conda-forge pypdf2.