ModuleNotFoundError: No module named 'fpdf'

11.7k Views Asked by At

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.

3

There are 3 best solutions below

0
On

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.

1
On

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.

1
On

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