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
  no module named 'docx' when importing docx MaartenRo 1 705 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  Problem with pymodbus - ModuleNotFoundError: No module named 'pymodbus.client.sync' stsxbel 2 22,931 Nov-02-2023, 08:20 AM
Last Post: South_east
  ModuleNotFoundError: No module named 'requests' Serg 18 2,156 Oct-29-2023, 11:33 PM
Last Post: Serg
  Resolving ImportError: No module named gdb (Python in C++) mandaxyz 3 1,308 Oct-04-2023, 02:43 PM
Last Post: mandaxyz
  ModuleNotFoundError: No module named 'PyPDF2' Benitta2525 1 1,388 Aug-07-2023, 05:32 AM
Last Post: DPaul
  ModuleNotFoundError: No module named 'eyed3' Wimpy_Wellington 2 1,221 Jul-10-2023, 03:37 AM
Last Post: Wimpy_Wellington
  How to fix this error: ModuleNotFoundError: No module named 'notears' yaoyao22 2 960 Jul-09-2023, 11:24 AM
Last Post: yaoyao22
  Help with pyinstaller "No module named" korenron 9 8,186 Jun-15-2023, 12:20 PM
Last Post: snippsat
  Problem with Pyinstaller. No module named '_tkinter' tonynapoli2309 0 932 May-15-2023, 02:38 PM
Last Post: tonynapoli2309
  ModuleNotFoundError: No module named 'omsdk.sdkproto' donvito7 4 1,769 Oct-20-2022, 02:56 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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