Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
apps:python:start [2022/11/29 17:26] enviadminapps:python:start [2023/03/12 22:15] (current) – [Python for ENVI-met] enviadmin
Line 1: Line 1:
 ====== Python for ENVI-met ====== ====== Python for ENVI-met ======
  
-Starting with Version 5, ENVI-met integrates scrpting and analysis using the powerful Python system.+Starting with Version 5, ENVI-met integrates scripting and analysis using the powerful Python system. This has become possible mainly thanks to the development of the excellent Python API header translation and wrappers  //Python for Delphi (P4D)// ([[https://github.com/pyscripter/python4delphi|GitHub Link]]).  P4D is licensed under the MIT license. ENVI-met Python Scripts are either MIT licensed or, like this manual, Creative Common BY-NC-SA 4.0, whichever is the less restrictive in use.  
  
-Over the last years, Python has established itself as universal scripting language for all thinkable use cases. Python covers an endless list of areas of expertise rangeing from data analysis and visiualision, application scripting or AI engineering. +Over the last years, Python has established itself as universal scripting language for all thinkable use cases. Python covers an endless list of areas of expertise ranging from data analysis and visualisation, application scripting or AI engineering. 
 To cut a long story short, there is almost no thinkable area of computer science where we might miss Python versions or Python integrations of the up-to-date code libraries or cutting edge technologies. To cut a long story short, there is almost no thinkable area of computer science where we might miss Python versions or Python integrations of the up-to-date code libraries or cutting edge technologies.
  
-From the perspecitve of ENVI-met, there are numerous ways we can benefit form the Python developements+From the perspective of ENVI-met, there are numerous ways we can benefit form the Python developments
-  * Processing, Analysis and Visiulaisation of model data +  * Processing, Analysis and Visualisation of model data 
-  * Controlling and scripting the behaviour of ENVI-met applicatons+  * Controlling and scripting the behaviour of ENVI-met applications
   * Extending the data interfaces of applications using Python libraries and packages       * Extending the data interfaces of applications using Python libraries and packages    
  
Line 18: Line 18:
 ==== Using the internal Python distribution ==== ==== Using the internal Python distribution ====
  
-ENVI-met ships with a small 64Bit Python distribution ensuring that minimal requirements and software dependencies are satisfied. However, in almost all cases, you will need to install addtional packages into the Python system that has become quasi-standard over the time. Typical packages that are required for almost all scripts are +ENVI-met ships with a small 64Bit Python distribution ensuring that minimal requirements and software dependencies are satisfied. However, in almost all cases, you will need to install additional packages into the Python system that has become quasi-standard over the time. Typical packages that are required for almost all scripts are 
 [[wp>NumPy]], [[wp>Matplotlib|MatPlotLib]] or [[wp>Pandas_(software)|Pandas]].     [[wp>NumPy]], [[wp>Matplotlib|MatPlotLib]] or [[wp>Pandas_(software)|Pandas]].    
 These packages need to be installed into the ENVI-met Python distribution after installing ENVI-met itelf to use most of the scripts related to ENVI-met.  These packages need to be installed into the ENVI-met Python distribution after installing ENVI-met itelf to use most of the scripts related to ENVI-met. 
-The ENVI-met Python distribution is completly local to ENVI-met, which means it does not interfere with other Python distributions you might have on your system. On the downside of this approach you will need to install additional packages into the local Python distribution.+The ENVI-met Python distribution is completely local to ENVI-met, which means it does not interfere with other Python distributions you might have on your system. On the downside of this approach you will need to install additional packages into the local Python distribution. 
 + 
 +ENVI-met DataStudio will support you in an automated install of the most required packages for ENVI-met. If DataStudio recognizes that e.g. Pandas is missing, if will prompt you to enter a quick install routine to add the missing modules (Internet access required) 
  
-ENVI-met  DataStudio will support you in an automated install of the most required packages for ENVI-met. If DataStudio recognizes that e.g. Pandas is missing, if will promt you to enter a quick install routine to add the missing modules (Internet access requird)  
  
 ==== Using my own Python distribution ==== ==== Using my own Python distribution ====
Line 29: Line 30:
 Many users already do have a working Python installation on their computers including all the packages and libraries they need for their daily work. Many users already do have a working Python installation on their computers including all the packages and libraries they need for their daily work.
 There is no need to double a Python distribution. Using the Workspace Manager, you can direct ENVI-met any time to use your personal installed Python distribution instesd of using and manage the embedded ENVI-met Python version. There is no need to double a Python distribution. Using the Workspace Manager, you can direct ENVI-met any time to use your personal installed Python distribution instesd of using and manage the embedded ENVI-met Python version.
 +
 +==== Make sure all required packages and modules are existing and matching ====
 +
 +Well, that's not possible. 
 +Any script can use its own set of required modules and libraries and the libs between each other may have dependencies, sometimes there are (version) conflicts which are not resolvable.
 +This is an issue related to programming in Python (or to programming in general) and it cannot be solved by ENVI-met.  This normally does not apply to scripts shipped with ENVI-met, but even here, updating single packages can result in crushing the command pipeline even in default scripts or bad dependencies between scripts may occure. 
 +
 +With BETA 3, you can add a list of required special modules in the script header and DataStudio will check, if they exist. If not (-and if selected as option-) DataStudio will automatically launch PIP and tries to install the missing modules and packages. We labelled these modules as //Special Modules// because modules which are not basically a part of Python, but are so basic that they need to exist on any system (such as NumPy or Pandas) will probably not be extra-listed in the Required Modules section.  
 +
 +However, there is no guarantee, that this install will be successful or that ALL of the required special modules have been listed in the header and that their versions will work together. If in doubt, you need to check the script in detail and go back to its sources to find out, what is missing.
 +
 +
  
 ==== Scripting ENVI-met apps in Python ==== ==== Scripting ENVI-met apps in Python ====
Line 40: Line 53:
 In addition, ENVI-met related objects are only available inside the ENVI-met DataStudio biotope. In the future we will also provide standalone packages for accessing fundamental operations such as reading and analysing EDX fies from other Python environments, but this is up-to-come. In addition, ENVI-met related objects are only available inside the ENVI-met DataStudio biotope. In the future we will also provide standalone packages for accessing fundamental operations such as reading and analysing EDX fies from other Python environments, but this is up-to-come.
  
-==== How to import python scripts from the website====+=====How to import python scripts (from the website====
 + 
 +Python scripts for ENVI-met are normal Python scripts, but use the ending .enpy in most cases. Only for libraries, the ending .py must be kept in order to work with Python.   
 + 
 +==== Add scripts automatically ==== 
 + 
 +  * Just double-click the downloaded ''.enpy'' script. This will launch ScriptCatcher where you can simply add the script to your library by clicking the "Add" button.
  
-=== Add scripts automatically ===+ {{ :apps:python:scriptcatcher.png?600 |nolink}}
  
-  * Just double-click the downloaded enpy-script. A dialog should appear where you can simply add the script to your library by clicking the button ("ScriptCatcher").+==== Launch ScriptCatcher manually ====
  
-=== Launch ScriptCatcher manually ===+Click on the Control icon top left in DataStudio and select "Run ScriptCatcher". You can also launch ScriptCatcher from the WINDOWS app menue.
  
-Click on the Control icon top left in Datastudio, and select "Run Scriptcatcher"+==== Add scripts manually ====
  
-=== Add scripts manually ===+If you want to manage several scripts in one go, a direct copy might be the quickest option.
  
   * Download the script   * Download the script
Line 57: Line 76:
   * Paste the script there   * Paste the script there
   * Reload the script library   * Reload the script library
-  * The imported script should now appear in your DataStudio if you click "All Scripts" at the top-right+  * The imported script should now appear in your DataStudio (you might need to click "All Scripts" at the top-right if no file context is set in DataStudio)
  
 Note: If you are not sure where your personal script folder is located, navigate to the Project Manager (Start Headquarter, switch to Data and Settings, click Projects / Workspaces). In the Project Manager the location of your personal script folder is printed at the bottom-right area under "Your folders". Note: If you are not sure where your personal script folder is located, navigate to the Project Manager (Start Headquarter, switch to Data and Settings, click Projects / Workspaces). In the Project Manager the location of your personal script folder is printed at the bottom-right area under "Your folders".