Pulsonix User Forum

Technical advice from Pulsonix engineers and the wider community.

Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Help with using Pulsonix
 Scripting
 Problems with Python Scripting / Installation Guid
Author Previous Topic Topic Next Topic  

marc

Germany
4 Posts

Posted - 14 Mar 2024 :  11:23:23  Show Profile  Reply with Quote
Hello everyone,

i need to create some scripts for exporting different data for our pick and place machine and for some other stuff.

Why i want to use python script:
The problem with java and vb script is, that there is now way to use some kind of graphical user interface.
The only way in combination with java or vb would be a HTA script (HTML-Application). But it looks like, that HTA is not supported in Pulsonix.
At least i could not get it running.
Also Pulsonix does not have any GUI objects itself, which could be used inside the scripts. I'm coming from Eagle and in Eagle the integrated ULP-scripting engine was very powerfull and had also GUI-objects which could be used inside the scripts.
So python comes with tkinter, which is a GUI library and so it is (together with TCL/TK) the only scripting language wich supports GUI.

So finally it took me 2 days to get python scripting running together with pulsonix.
Because there are allready two posts in this forum asking for python scripting
https://www.pulsonix.com/forum/topic.asp?TOPIC_ID=385 and
https://www.pulsonix.com/forum/topic.asp?TOPIC_ID=64
but sadly no satisfying answers on this posts, i want to share my experience i made with the installation of python scripting.

First i tried with the newest Python Version 3.12. But this version is not running at all. This is because the additional pywin32 module (which is needed to use python in the windows scripting host) still uses the imp library, which is deprecated since python version 3.4 and was finally removed in version 3.12.

Then the second try was with Python Version 3.10. This version i could get running, but the problem with this version is, that pulsonix crashs and just closes without any warning or error message, after the script execution has finished! So in my opinion this is a pulsonix problem. (Meanwhile i got an answer from pulsonix support team, that Pulsonix is not compatible with python version later than 2.7, what is really sad, because python 2.7 is deprecated since 2020. So in my opinion WestDev should fix this as soon as possible!! Also because WestDev is advertising a wide scripting system in pulsonix. Also that was one of the main reasons in our company why we switched from Eagle to Pulsonix and not to another ECAD-System)

So i switched to the latest python2 (version 2.7). But python2 is deprecated since 2020. At least i could get it running without crashing pulsonix on executing the scripts :)

Because in the installation guide in the pulsonix Help, which is difficult to find, are missing a few important things, i will share a quick installation guide here for other pulsonix users:

1. you have to download and install python2 (64bit). The latest version is 2.7.18.
You have to install it with admin rights. You also need to check the option, that the path environment-varibale will be set during installation.
2. After installation you need to manually add another environment-variable PYTHONPATH wich also points to the python folder where it was installed.
3. Open a command console (cmd) in windows and switch to the folder where python 2.7 is installed. It is important that you run the console with administration rights, otherwise the python com extension can't be registered correctly.
4. Install the pywin32 module via pip by using the following command:
python -m pip install pywin32
It could be possible that you need to upgrade pip first by using the command:
python -m pip install --upgrade pip
5. In python subfolder Lib\site-packages\win32comext\axscript\client you need to exchange the framework.py file with the one you get from WestDev development team. Sadly this file is not included somewhere in the pulsonix installation folder. You have to request it from Pulsonix support team separately.
6. In console switch to the subfolder Lib\site-packages\win32comext\axscript\client of your python installation folder and run the following command to register the com extension with the windows scripting host:
python pyscript.py
7. In console switch to the subfolder scripts\ of your python installation folder and run the following command to copy the necessary python files to the windows system folders:
python pywin32_postinstall -install
8. Now everything should be installed correctly. You can test this by executing the following command in the console:
cscript your_own_python_test_script.pys
If cscript runs without any message that python is not recognized as scripting language, then everything should be fine and your scripts should run from pulsonix.

greetings from germany
marc

Edited by - marc on 14 Mar 2024 11:24:20
  Previous Topic Topic Next Topic  
Jump To: