Sunday 26 February 2017

Auto Import Python libraries at startup


*Requirements Below description is applicable for Linux OS

Create a file auto_import.py 

import numpy as np
import pandas as pd
#.... and so on...
#with all your import statements 

In Terminal 

1. Open $HOME/.bashrc file

$ gedit $HOME/.bashrc

2. Copy paste the following line at the end of file:   

#be sure of the path you provide

export PYTHONSTARTUP=/path/to/auto_import.py 

3. Save and close the file 

4. Relaunch the Terminal or use command below to execute changes in bashrc file

$ exec bash

4.In terminal

$ python 

>>> #Congratulations!!! all your libraries are auto imported.

 


No comments:

Post a Comment