18

As a newbie... I am having difficulties installing pyPDF2 module. I have downloaded. Where and how do I install (setup.py) so I can use module in python interpreter?

3
  • 1
    If you have the easy_install module, you can just do python -m "easy_install" PyPDF2
    – GVH
    Commented Feb 28, 2014 at 21:49
  • 2
    yes, but you will need to add python to your PATH environment variable if you are on Windows. If you don't want to bother with that, you can type out the full path to the python executable (Probably C:\\Python27\python.exe) instead of just "python".
    – GVH
    Commented Feb 28, 2014 at 23:55
  • Official docs - please let me know if you have a suggestion for improving them Commented Apr 22, 2022 at 21:07

4 Answers 4

22

If you have pip, PyPDF2 is on the Python Package Index, so you can install it with the following in your terminal/command prompt:

Python 2:

pip install PyPDF2

Python 3:

pip3 install PyPDF2

13

To install setup.py files under Windows you can choose this way with the command line:

  1. hit windows key
  2. type cmd
  3. excute the command line (black window)
  4. type cd C:\Users\User\Downloads\pyPDF2 to go into the directory where the setup.py is (this is mine if I downloaded it) The path can be copied from the explorer window.
  5. type dir now you should see the name setup.py in the listing of all contents
  6. type C:\python27\python.exe setup.py install I use Python2.7 here. Use C:\python33\python.exe setup.py install for python 3.3 and so on. You can follow these instructions now if you wish: http://docs.python.org/2/install/index.html

Another way, that does not show when there are problems, is:

  1. create a shortcut to setup.py
  2. open the properties of the shortcut. There should be a path like this: C:\Users\User\Downloads\pyPDF2\setup.py (this is where my setup.py is)
  3. you modify that path in the following way:

    "C:\Users\User\Downloads\pyPDF2\setup.py" install
    

    The " are important if you have white spaces in the path name

  4. click OK to save the modifications to the setup.py - shortcut
  5. double-click the setup.py - shortcut.

In all cases you may need to restart your python to be able to import the module.

When you do this feel free to post your solution also with pictures for other newbies looking for it.

2

If you have pip, use it to install PyPDF2 from the command line:

For python2:

pip install PyPDF2

For python3:

pip3 install PyPDF2

Note that if you have multiple versions of python3 installed, you will need to be very explicit. Ex, for Python 3.7:

py -3.7 -m pip install PyPDF2

Read more here.


In case you need to upgrade your pip installer:

To upgrade pip (for Python 2) in Windows (or Linux, I think):

python -m pip install --upgrade pip

To upgrade pip3 (for Python 3):

1) in Windows:

py -3 -m pip install --upgrade pip

OR if you need to be explicit since you have multiple 3.x versions installed:

py -3.7 -m pip install --upgrade pip

2) In Linux I think it is:

python3 -m pip install --upgrade pip
1
  • python -m pip install --upgrade pip this will not work for me system python 2.7 and python 3.7 currently, i am using venv i am trying to install pip install pypdf2
    – Mr Coder
    Commented Feb 13, 2020 at 8:54
1

Here's how I did it: After you have downloaded and installed Python (it usually installs under C:\Python** (** being python version - usually 27)), copy the extracted PyPDF2 contents to C:\Python** folder, after that enter in command prompt/terminal "cd C:\Python27\python.exe setup.py install". If you did everything right it should start installing PyPDF2.

Not the answer you're looking for? Browse other questions tagged or ask your own question.