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 'pysolar' - even tough pysolar is installed - What am I doing wrong? Jghurt 5 417 May-08-2021, 07:03 PM
Last Post: Jghurt
  ModuleNotFoundError: No module named 'graph' Anldra12 3 562 May-02-2021, 02:41 PM
Last Post: Anldra12
  fpdf orientation not working properly KatMac 1 289 May-02-2021, 10:47 AM
Last Post: Pedroski55
  fpdf star character issue KatMac 3 319 May-01-2021, 06:22 PM
Last Post: KatMac
  fpdf adding a new font to my report KatMac 0 213 Apr-23-2021, 02:19 PM
Last Post: KatMac
  ModuleNotFoundError: No module named 'com' aleksg 9 1,307 Dec-14-2020, 05:00 PM
Last Post: Larz60+
Video ModuleNotFoundError: No module named ‘…’ Frank911 1 1,029 Dec-11-2020, 03:59 PM
Last Post: michael1789
  no module named finbert found ErnestTBass 4 833 Dec-05-2020, 06:09 PM
Last Post: andrianas
  ModuleNotFoundError: No module named 'fcntl' ErnestTBass 2 3,970 Dec-05-2020, 02:39 PM
Last Post: ErnestTBass
  ImportError: No module named coltson 3 800 Nov-21-2020, 10:22 AM
Last Post: Superjoe

Forum Jump:

User Panel Messages

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