How to preload some libraries and scripts in python before I call python command? Is there something like .bashrc file to deal with predefining some functions/variables befo
i wanted to sometimes run python with a bunch of statistics/math stuff loaded (numpy, matplotlib, etc), but othertimes just a simple python without having the overhead of loading modules i wasn't going to use.
i use ubuntu linux, so i created a python script python-preload.py
with the following:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
and added an alias to my ~/.bashrc
:
alias pym='PYTHONSTARTUP=/home/$USER/path/to/script/python-preload.py python'
so when i want normal python i run python
, and when i want all the math stuff i run pym
.
hope this helps. based off Tony Blundell's answer.