Jump to content

GOM 2022 - Install Python Package via script if not detected?


---
 Share

Recommended Posts

Greetings! Our company has just made the jump from ATOS V8 SR1 to GOM 2022, and I am in the process of updating our scripts to the newer software syntax. Several of our scripts utilize the openpyxl module, which I had previously imported by piggybacking it off of an external python interpreter, but am now directly installing to the GOM interpreter. I'm using the "right-click on user-defined scripts --> Install Python Package" method for this, but for other end users of my scripting who may not have this module installed yet I am wondering if it is possible to automate this installation process? I'm thinking my script would try to import the module, and if it cannot be found attempt to download, install, and re-import the module without requiring the user to do it manually. Something like the following:

try:
      import openpyxl
except:
      try:
            Install_Python_Package(openpyxl) #Call the install python package script and automatically feed it openpyxl as an argument to install the module from the network
            import openpyxl
      except:
            #Error message to inform end user that package wasn't installed/imported

Is it possible to automate the installation of required python packages in this way? Thanks!

Michael Henson

Link to comment
Share on other sites

  • 1 year later...
---

Hi,

you could try the following:

Please note that I did not test this yet.

Best regards,

Matthias

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...