0

I would like to import pdfplumber and tried

import pdfplumber

and caught error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-b3d6737fd8e1> in <module>
----> 1 import pdfplumber

ModuleNotFoundError: No module named 'pdfplumber'

Tried to install using pip3 install pdfplumber and it returned:

Requirement already satisfied: pdfplumber in c:\python38\lib\site-packages (0.5.26)
Requirement already satisfied: pdfminer.six==20200517 in c:\python38\lib\site-packages (from pdfplumber) (20200517)
Requirement already satisfied: Wand in c:\python38\lib\site-packages (from pdfplumber) (0.6.5)
Requirement already satisfied: Pillow>=7.0.0 in c:\python38\lib\site-packages (from pdfplumber) (7.2.0)
Requirement already satisfied: sortedcontainers in c:\python38\lib\site-packages (from pdfminer.six==20200517->pdfplumber) (2.3.0)
Requirement already satisfied: chardet in c:\users\harper.guo\appdata\roaming\python\python38\site-packages (from pdfminer.six==20200517->pdfplumber) (3.0.4)
Requirement already satisfied: pycryptodome in c:\python38\lib\site-packages (from pdfminer.six==20200517->pdfplumber) (3.10.1)
WARNING: You are using pip version 20.3.3; however, version 21.0.1 is available.
You should consider upgrading via the 'c:\python38\python.exe -m pip install --upgrade pip' command.

But Command Prompt showed that I already have installed the module?

>>> pdfplumber
<module 'pdfplumber' from 'C:\\Python38\\lib\\site-packages\\pdfplumber\\__init__.py'>

But import pdfplumber returned the same erro. How to import pdfplumber?

nilsinelabore
  • 2,021
  • 3
  • 14
  • 45

1 Answers1

0

I guess it has to do with the Python version that I used.

In the top right hand corner of VS Code it shows that my Python version was Python 3

enter image description here

Clicking on it and changing it to Python 3.8.5 and the code worked. This was done after I restarted VS Code and my laptop, and created new path.

enter image description here

Creating a new path in Environment Variables following these resources:

1. 'pip' is not recognized as an internal or external command

2. 2020 How to Fix "No Module Named..." Error in Python | Python Tutorial

3. Python Virtual Environments: A Primer

4. '' is not recognized as an internal or external command, operable program or batch file

nilsinelabore
  • 2,021
  • 3
  • 14
  • 45