Griffin Bell
Griffin Bell

Reputation: 131

ModuleNotFoundError: No module named 'fpdf'

Getting this error: ModuleNotFoundError: No module named 'fpdf'

I've re-downloaded python, created a new venv and installed fpdf2 using pip install fpdf2, but I still get this error when I run from fpdf import FPDF

python version: 3.10.4

I've looked all over stack overflow and through the github issues and haven't found any solutions, and have no idea what to try next.

Upvotes: 5

Views: 19408

Answers (3)

Griffin Bell
Griffin Bell

Reputation: 131

I was using VSCode's Jupyter extension and it wasn't using the same virtual environment that the terminal was using - so the install wasn't going to the right place. Once I aligned the two virtual environments, it worked fine.

Upvotes: 2

diana18
diana18

Reputation: 120

This may be silly but should you be using fpdf2 instead of fpdf? Because if that's the name then it needs to be exact.

from fpdf2 import FPDF

Otherwise if you are using an IDE, then you may need to download the package into the IDE. For example in PyCharm I had to go to Python Packages and install it through there even after pip. Probably some path related issue.

Upvotes: 0

Ballack
Ballack

Reputation: 966

firstly please make sure that you want fpdf or fpdf2 lib, these are two different lib.

It seems that you want fpdf, so you need to try:

pip install fpdf

Upvotes: 3

Related Questions