I have a Python code that I have to send to my teacher. The issue is that I import the following packages :
import numpy as np
import matplotlib.pyplot as plt
import datetime as date
import ephem
I would like to create an archive .tar with my Python code inside but also all the necessary packages (numpy, matplotlib, datetime
and the important ephem
) to make the Python code running. Indeed, I am not sure that my teacher has all these packages installed on his computer.
Is it possible to perform this action in order to, for my teacher, unzip archive .tar and just do "python source.py" to get the code running without missing packages ?
The standard way would probably be to distribute a requirements.txt
file that the pip
command understands. i.e. you'd create the file containing:
numpy
matplotlib
ephem
and these would be installed by doing:
pip install -r requirements.txt
which would cause those packages to be installed. Note that you can include version numbers and other specifications in the requirements file if needed.
Note that we do this because installing packages like numpy
can be non-trivial due to dependencies like BLAS which can be awkward to get configured under arbitrary OSs.