I am currently finishing a school project making a game of Blackjack. I was using Replit to code and everything was fine. I recently tried to run it at home on Visual Studio Code but it said a module named "matplotlyb.pyplot" wasn’t installed. I seem to understand now that you have to install it manually. When my project is done, it will be sent to an external examiner who will review it. Is there anyway to automatically download the module when the code is ran so the examiner won’t have to?
Here’s what I’m looking for:
import matplotlib.pyplot as plt
#something that installs it if not already installed
2
Answers
Best practice would be to include a requirements.txt file along with your project. The file should contain all the required packages in the format
You could also use the below to generate the requriements.txt
pip freeze
gives you the list of all installed Python modules along with the versionsTo run your install all the dependencies, you could just use:
Hope this helps!
Simply wrap things in a
try.. except
and don’t forget to usesys.executable
to ensure that you will call the samepip
associated with the current runtime.