Zeus and ActiveState Python

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Zeus and ActiveState Python

Post by jussij »

Neil wrote:

I am not able to import these libraries from within Zeus.

Code: Select all

import dbi 
import odbc 
import win32com.client 
import ftplib 
import time 
import os 
import string 
from pprint import pprint

These libraries are pretty critical for allowing Python to automate Zeus.

I did perform some additional research and discovered that Zeus was using a different version of Python than me. (Zeus uses 2.4, I was using 2.3)

I upgraded my version of Python and set some environment variables (to find the libraries) that had not been previously set.

Now most of the imports work. Those imports that are loaded from a .py or .pyc (source files) work fine. Those imports that are loaded from executables (dll) cause Zeus to abort with the following error message:

Code: Select all

Messagebox title is Microsoft Visual C++ Runtime Library

Runtime Error!

Program:  C:\Program Files\Zeus\zeus.exe

This application has requested the Runtime to terminate in an unusual way.  
Please contact the application's support team for more information.
For some reason, the Zeus version of Python seems to have trouble importing dlls that come with my version of Python (ActiveState).

If you have an easy fix or work around, I would appreciate it. However, I can implement just about macro functionality I need using vbscript instead of Python. (But I prefer coding in Python)
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

To test this problem I downloaded and installed the ActiveState Python package and created this simple d:\temp\bug.py test macro:

Code: Select all

import win32api

def key_macro():
    win32api.Beep(400, 250)

key_macro() # run the macro
If I run this from the command prompt using the command:
d:\python24\python.exe d:\temp\bug.py
and sure enough the speaker puts out the expected beep.

Next I ran the macro from within Zeus and sure enough I get an unexpected runtime error :(

So I repeated the test using the Zeus debug version from within the debugger and strangely enough this time Zeus does not crash, but instead displayed this message in the Zeus debug output window:
D:\work\scriptpy\Python24\test>python d:\temp\bug1.py
Traceback (most recent call last):
File "d:\temp\bug1.py", line 1, in ?
import win32api
ImportError: No module named win32api
So I downloaded the latest latest Python installer from python.org website and ran the test script using the version of the python.exe that comes with this package. When I do this I get the exact same output as was produced in the Zeus debug test :?

Next I then linked Zeus against the ActiveState Python24.lib file and repeated the test with the release build. This time Zeus does not crash but instead generates protection fault which causes the execption dialog to be displayed.

So after all this testing I still have no idea why it is not working :(

But since the Zeus Python is built from the source code found at the offical Python site, this explains why the Zeus debug and Python version report the same error message when running the test macro.

I am sure why the release version generates the runtime error. I would have expected it to report the same error message :?

But it also appears the ActiveState does something special with their builds since even if I link to their lib and use their dll files it still does not work :(

Cheers Jussi
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

As a further test to determine where Python was picking up it's imports I ran this test script:

Code: Select all

import sys
import zeus

def key_macro():
    zeus.debug_enable()
    zeus.debug_output("sys.path = [\n")
    for dir in sys.path:
        zeus.debug_output(" %r\n" % (dir,))
    zeus.debug_output("]")

key_macro() # run the macro
This macro generated the same output for both debug and release version of Zeus:

Code: Select all

Debug: Debug: Macro trace debugging is active.
Debug: debug_output
sys.path = [
Debug: debug_output
 'D:\\work\\zeus\\Release\\xpython24.zip'
Debug: debug_output
 'D:\\work\\scriptpy\\Python24\\Lib'
Debug: debug_output
 'D:\\work\\scriptpy\\Python24\\DLLs'
Debug: debug_output
 'D:\\work\\scriptpy\\Python24\\Lib\\lib-tk'
Debug: debug_output
 'D:\\Python24\\Lib'
Debug: debug_output
 'D:\\Python24\\DLLs'
Debug: debug_output
 'D:\\Python24\\Lib\\lib-tk'
Debug: debug_output
 'D:\\work\\zeus\\Release\\zScript'
Debug: debug_output
 'D:\\work\\zeus\\Release'
Debug: debug_output
 'D:\\Python24'
Debug: debug_output
 'D:\\Python24\\lib\\site-packages'
Debug: debug_output
 'D:\\Python24\\lib\\site-packages\\win32'
Debug: debug_output
 'D:\\Python24\\lib\\site-packages\\win32\\lib'
Debug: debug_output
 'D:\\Python24\\lib\\site-packages\\Pythonwin'
Debug: debug_output
]Macro produced '33' Warning(s), Error(s) and/or Debug(s) messages.
So what I think is happening is the import is finding the package in both cases but in trying to load the package in release mode the program is crashing, while in debug mode the load is just failing.

My guess is the build switches used by ActiveState are slightly different to those used in Zeus and this is creating the problem :(

Cheers Jussi
nedmunds
Posts: 5
Joined: Mon Nov 28, 2005 9:58 pm

Post by nedmunds »

Jussi,

Thanks for researching this. Next week I will test the Python from Python.org to see I can set it up to perform everything I need. (Active State includes some libraries in their distribution that are not in the official distribution...I do not know if any of my scripts use these). This will take some time because I have over 100 active scripts, many over 1000 lines long.

Hopefully I will be able to replace Active State with the official distribution and use Python for scripting Zeus.

-Neil
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

The latest Zeus patch can now run this simple Python macro:

Code: Select all

import win32api 

def key_macro(): 
    win32api.Beep(400, 250) 

key_macro() # run the macro
But even this release will most probably not work with ActiveState, but instead you need to use the official Python release.

Cheers Jussi
Post Reply