Using Python scripts with an installed Python program(Python v3.10)

Python installation and configuration

  1. Download and install the Python program

    1. You can down Python v3.10 at https://www.python.org/downloads/release/python-3101/.

    2. Select “Windows installer (32-bit)”.

    3. Install Python. Make sure that the Add Python 3.10 to PATH option is checked.

       

  2. Install Pywin32

    1. Run Command Prompt as an Administrator.

    2. Use the following command to install Pywin32.

      python -m pip install pywin32

       

  3. Register Pywin32 to the Registry.

    1. Run Command Prompt as an Administrator.

    2. Run the following commands.

      cd C:\Users\["UserName"]\AppData\Local\Programs\Python\Python310-32\Lib\site-packages\win32comext\axscript\client python .\pyscript.py

       

  4. Copy the relevant files to your Python installation location.

    1. Move to C:\Users\["UserName"]\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pywin32_system32 folder

    2. Copy the following two files to the Python installation path (default path: C:\Users["UserName"]\AppData\Local\Programs\Python\Python310-32).

      cd C:\Users\["UserName"]\AppData\Local\Programs\Python\Python310-32\lib\site-packages\pywin32_system32 copy pythoncom310.dll C:\Users\["UserName"]\AppData\Local\Programs\Python\Python310-32 copy pywintypes310.dll C:\Users\["UserName"]\AppData\Local\Programs\Python\Python310-32

       

  5. Change a Registry value

    1. Find \HKEY_CLASSES_ROOT\WOW6432Node\CLSID\{DF630910-1C1D-11d0-AE36-8C0F5E000000}\InprocServer32 key.

      • Note: You can quickly find this by searching ‘pythoncom’ in the \HKEY_CLASSES_ROOT\WOW6432Node\CLSID\ path.

    2. Change the value of the registry to the path of the copied file (Python installation folder\Pythoncom310.dll).
      (Python Default Path : C:\Users\["UserName"]\AppData\Local\Programs\Python\Python310-32\Pythoncom310.dll)

       

Xshell Configuration

  1. Turn on the ‘Do not use Xshell’s embedded Python' option in the global options (Tools → Options → Advanced).

  2. Run your Python script.

  3. If the installation or settings are not configured properly, the following error can occur.