'FPDF Import Error: cannot import name 'FPDF' from 'fpdf' (unknown location)

I'm using Python 3.8.5, conda 4.10.3 and FPDF2 2.3.1

When I try to import the package, I get the following error:

Input:

from fpdf import FPDF

Response:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/var/folders/q3/38dtckns13b368s1x7g59hh40000gn/T/ipykernel_917/4051462934.py in <module>
----> 1 from fpdf import FPDF

ImportError: cannot import name 'FPDF' from 'fpdf' (unknown location)

I have uninstalled and reinstalled FPDF2 several times, both from PyPI pip install fpdf2 and from anaconda conda install -c conda-forge fpdf2.

Installation is successfull but code keeps running with errors.



Solution 1:[1]

Try to uninstall the module through this command:

pip uninstall fpdf2

then again install the module with this command:

pip install fpdf2

Hope this will work. :)

Solution 2:[2]

I solved the problem downloading fpdf from pip, instead of Anaconda, after being adviced by the fpdf team.

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 Muhammad Nur
Solution 2 Portfedh