BernardoFire BernardoFire - 5 months ago 50
Python Question

use "pip install/uninstall" inside a python script

how, inside a python script can I install packages using pip?
I don't use the os.system, I want to import pip and use it.


It's not a good idea to install packages inside the python script because it requires root rights. You should ship additional modules alongside with the script you created or check if the module is installed:

   import ModuleName
except ImportError:
   print 'Error, Module ModuleName is required'

If you insist in installing the package using pip inside your script you'll have to look into call from the subprocess module ("os.system()" is deprecated).

There is no pip module but you could easily create one using the method above.