pythonpluginsqgis

QGIS python plugins: How to install python packages, f.e. cx_Oracle


I want to develop a python- plugin for QGIS. For this I need to install packages (f.e. cx_Oracle) on my computer and of course - when deployed on client- computers. Can anyone tell me, how to do this, preferably without the need for admin rights?


Solution

  • Solution

    import sys
    import subprocess
    
    def Package_Install(package):
        subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])
    

    You can install Python packages using the OS shell. The sys.executable gets the Python interpreter used by the application, and the rest of the variables are command line arguments. You will not need administrator privileges because this operation will require the same level of privileges as the Python application.

    Result

    Script terminal output

    enter image description here

    enter image description here

    enter image description here

    enter image description here