How to check whether openpyxl package exist and if it is not exist how to download and install it within the script in Python 3.5.1? : I started writing python codes two weeks ago and until now I have manipulate some excel data after converting it to txt file. I want to manipulate excel data directly, so I need to install openpyxl package. However, my script will be used in many different places and computers (note that: all of them either OS X or a Linux distrubution) which might (probably do not) contain openpyxl package installed. I want my script to check whether this package exist, and if it does not exit, then download and install it. 

For that purpose, as I searched and found that I could check the existence of the package by first importing the pip module and then pip.get_installed_distributions() method. However, I am not sure whether I am in a wrong way or not. Beside, I have no idea how to download and install openpyxl package "without leaving the script". 

Would you like to help me ?