Python Forum
ModuleNotFoundError: No module named 'fpdf'
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ModuleNotFoundError: No module named 'fpdf'
#1
I am running Windows 10, using the VSC editor and Python 3.9.4
My goal is to convert an existing csv file to a pdf.

I installed the required module by entering: pip install fpdf. Then I wrote a few lines of code and decided to check and see if the installation worked before I continued. It did not as I received the above mentioned error message.

I then went to my environment variables and added in this path:
C:\Users\Owner\AppData\Local\Programs\Python\Python39\Scripts\\lib\

That did not work, so then I did this:
C:\Users\Owner\AppData\Local\Programs\Python\Python39\Scripts\lib\site-packages\fpdf

Closed down the apps and re-booted my computer.

Re-ran my code and I get the same error.

How can I resolve this issue

Wall
Reply
#2
(Apr-18-2021, 07:17 PM)KatMac Wrote: I then went to my environment variables and added in this path:
C:\Users\Owner\AppData\Local\Programs\Python\Python39\Scripts\\lib\

That did not work, so then I did this:
C:\Users\Owner\AppData\Local\Programs\Python\Python39\Scripts\lib\site-packages\fpdf
Do not do this.
Do pip -V this the Python version it install to.
Example.
# Show path to version it install to
C:\code
λ pip -V
pip 21.0.1 from c:\python39\lib\site-packages\pip (python 3.9)

# Install
C:\code
λ pip install fpdf
Collecting fpdf
  Downloading fpdf-1.7.2.tar.gz (39 kB)
Using legacy 'setup.py install' for fpdf, since package 'wheel' is not installed.
Installing collected packages: fpdf
    Running setup.py install for fpdf ... done
Successfully installed fpdf-1.7.2

# Test that it work
C:\code
λ python
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from fpdf import FPDF
>>>
>>> pdf = FPDF()
>>> pdf.add_page()
>>> pdf.set_font('Arial', 'B', 16)
>>> pdf.cell(40, 10, 'Hello World!')
>>> pdf.output('tuto1.pdf', 'F')
''
>>>
Now that all work from command line make sure that down in left corner VS Code,
that same version as tested over is used.
Python 3.9/3.8 and pip installation under Windows
VS Code from start
Reply
#3
Hi
I tried what you said and it still doesn`t work.
Getting same error as before:
ModuleNotFoundError: No module named 'fpdf'
Reply
#4
Do pip show fpdf.
Can do test in VS Code to and i am pretty sure that it work🔨
As in image under click down in left corner and make sure that same root path to Python match.
So in my case that is C:\Python39\...
For you it should be C:\Users\Owner\AppData\Local\Programs\Python\Python39\...
[Image: TOV6H1.png]
Reply
#5
Hi

I decided to uninstall and reinstall python
issue is resolved now.

Thank you for helping me.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ModuleNotFoundError: No module named 'tkcalendar', Thonny, Windows 10 Edward_ 4 946 Apr-06-2025, 07:56 PM
Last Post: Edward_
  No module named 'importlib.metadata' EdVS 3 1,144 Jan-30-2025, 09:55 AM
Last Post: Larz60+
  ModuleNotFoundError: No module named 'athena_read' raman 2 1,347 Jul-01-2024, 07:52 AM
Last Post: Gribouillis
  no module named 'docx' when importing docx MaartenRo 1 5,843 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 31,410 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 10,369 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 4,602 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 3,970 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 3,309 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 2,508 Jul-09-2023, 11:24 AM
Last Post: yaoyao22

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020