[Mi...] Posted April 19, 2023 Share Posted April 19, 2023 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 More sharing options...
[Ma...] Posted April 26 Share Posted April 26 Hi, you could try the following: Install the required package with pip · PyPI by executing pip from the script (Please make sure to used pip from the Python installation used by ZEISS INSPECT; see Frequently asked questions — Add-On Documentation (zeissiqs.github.io)) Execute gom.script.sys.update_addon_database() (if required) Try the import again Please note that I did not test this yet. Best regards, Matthias Link to comment Share on other sites More sharing options...
[Ma...] Posted April 26 Share Posted April 26 See User Guide - pip documentation v24.1.dev0 (pypa.io) Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in