'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.



Solution 1:[1]

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.

Solution 2:[2]

Try pip install fpdf With no 2.

Also make sure you're in the same env.

Solution 3:[3]

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

Solution 4:[4]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Griffin Bell
Solution 2 Lautaro Rojas
Solution 3 Ballack
Solution 4