Python Has Failed To Initialize Using DIAdem

Updated Aug 20, 2020

Reported In

Other

  • DIAdem 2020
  • Python

Issue Details

I want to use Python with DIAdem 2020 via the Python installation directory provided in DIAdem 2020. When I try to run the script, I get the following errors:

Initializing Python has failed.
Python is not initialized.


Solution

  1. Make sure the Python bitness matches the DIAdem bitness. DIAdem 2019 and 2020 are available in 64-bit only.
  2. Use a Python version 3.7.xxx as DIAdem supports Python up to version 3.7.
  3. Make sure the Path in environment variable for Python is included.
  • If you want Python to work across multiple users, check that the Python directory is added to PATH in both User Variables and System Variables.
  • Manually add/copy the path if required.
  1. Run DIAdem as Administrator.
  2. Use Python ‘pip’ installer to check for PYwin32 library to interface with DIAdem.
  3. Add the directory location of the Python engine to DIAdem Settings:
    1. In DIAdem, navigate to Settings >> DIAdem Settings.
  1. Click on SCRIPT under the Panels section. 
  2. Select Python as the Script language
  3. Input the directory location pointing to the Python engine as the Python Installation Path. For example, the path to the standard python engine that ships with SystemLink would be: C:\Program Files\National Instruments\Shared\Skyline\Python\3.7\

  1. Click OK.

 

  1. Use ‘sys’ library to append custom user module paths (within DIAdem scripts) so DIAdem and Python know where to look to import the libraries.
import sys
sys.path.append('C:\\Users\\.....\\User Designed Modules')
 
 

Additional Information

DIAdem 2020 does not support virtual Python environments. Only real Python engines install to dedicated directories registered with the OS.