#๐Ÿ”’ Error when running an exe file "No module named 'matplotlib'" | pyinstaller

4 messages ยท Page 1 of 1 (latest)

bitter trail
#

I am getting the same error when trying to run the exe file about matplotlib, which is the only library that throws me this error. The code works when I run it in VS Code but doesn't work as an exe file. This is the command I use: pyinstaller PlotBlackHoleData.py --onefile --windowed --debug=all --hidden-import matplotlib --hidden-import matplotlib.pyplot --hidden-import csv --hidden-import tkinter --hidden-import tkinter.filedialog
And this is the error I get:

  File "PlotBlackHoleData.py", line 2, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'matplotlib'```

These are the imports which are at the start of my code:
```import csv
import matplotlib.pyplot as plt
import tkinter as tk
from tkinter import *
from tkinter import filedialog```

Until now I have tried:
- Downgrading matplotlib to v 3.2.2 (which throws an error)
- Downgrading pyinstaller (doesn't work)
normal jacinthBOT
#

@bitter trail

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

normal jacinthBOT
#

@bitter trail

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.