BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rasc42
Fluorite | Level 6

Hello there,

 

Based on the VBS script generated when we choose the "Schedule" option on EnterpriseGuide our team is trying to automate the exeuction os SAS programs on Python by using PyWin32/win32com.

 

In my colleague's computer it runs fine, but in mine, I get this error:

 

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 89, in _GetGoodDispatch
    IDispatch = pythoncom.connect(IDispatch)
pywintypes.com_error: (-2147221021, 'Operation unavailable', None, None)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\xxxxxxx\Desktop\test.py", line 4, in <module>
    sas = EnsureDispatch('SASEGObjectModel.Application.7.1')
  File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\gencache.py", line 527, in EnsureDispatch
    disp = win32com.client.Dispatch(prog_id)
  File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch
    dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
  File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 114, in _GetGoodDispatchAndUserName
    return (_GetGoodDispatch(IDispatch, clsctx), userName)
  File "C:\ProgramData\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 91, in _GetGoodDispatch
    IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147024809, 'The parameter is incorrect.', None, None)

When I've tried using makepy to generate a py model of the object, I've got this message:

Could not locate a type library matching 'SASEGObjectModel.Application.7.1'

 

But by using this simple VBS script:

 

Set app = CreateObject("SASEGObjectModel.Application.7.1")

WScript.echo app.Name

 

i'm able to see a message box with "Enterprise Guide" written on it. So it seems the COM object is correctly registered on my system.

 

I would be glad for any kind of help 😃

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

No.  BLAME THE PYTHON was my natural response, but I suppressed it here in the interest of inter-tool peace.

SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.

View solution in original post

15 REPLIES 15
ChrisHemedinger
Community Manager

Bitness matters.  Are you using 32- or 64-bit SAS Enterprise Guide?  Whatever the answer, the Python runtime would need to match.

 

When you successfully run with VB Script, what's the runtime?  Is it the 32-bit version:

 

c:\Windows\SysWOW64\cscript.exe

 

Or the 64-bit version (yes, don't let that "system32" folder name throw you off...)

 

c:\Windows\System32\cscript.exe

 

SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.
rasc42
Fluorite | Level 6

Both Python and SAS are 64-bit, as you can see below:

 

python.PNG

sas.PNG

 

About the VBScript, if I try to run it directly with the cscript.exe from the SysWOW64 folder, it throws me an error, while the one at System32 runs fine, so I'm guessing I'm using the 64-bit one as well.

 

thanks

ChrisHemedinger
Community Manager

It is possible that the SAS EG automation model isn't properly registered on your machine -- but then I would not expect the VB script to work.

 

  • Run this command, and then try the script again.
    • "C:\Program Files\SASHome\SASEnterpriseGuide\7.1\SEGuide.exe" /register
  • If that doesn't work, try:
    • "%windir%\Microsoft.NET\Framework\k\v4.0.30319\RegAsm.exe" /codebase /tlb "C:\Program Files\SASHome\SASEnterpriseGuide\7.1\SASEGScripting.dll"

 

(Check the above paths to make sure they match where things are on your machine.)

SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.
rasc42
Fluorite | Level 6

Ran both commands on my computer. Just had to change the 2nd one to remove the "\k\" from the path (in "Framework\k\v4.0.30319").

 

Both ran without errors, apparently

scripts.PNG

 

But still getting the same error.

ChrisHemedinger
Community Manager

Okay, back to basics.  Can you use your Python environment to create an instance of a different object?  Like "Word.Application"?

SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.
rasc42
Fluorite | Level 6

Sorry for taking so long to answer, but yes, I'm able to create instances of any office application's object using python.

ChrisHemedinger
Community Manager

As this is working for your colleague, I'd compare a few things.

 

Check output of this command (from a command prompt):

 

32-bit EG: 

  reg query HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{6517AA37-C08D-4721-9723-BEBA806C56F9} /s

 

64-bit EG: 

  reg query HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{6517AA37-C08D-4721-9723-BEBA806C56F9} /s

 

 

SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.
rasc42
Fluorite | Level 6

So, as far as I can tell, they are both the same, I asked my colleague to run those commands, and it didn't find the WOW6432Node's key in his computer. So probably my Dispatch is trying to read from the 32-bit DLL, right?

 

output32.PNGoutput64.PNG

ChrisHemedinger
Community Manager

The WOW6432 entry indicates a 32-bit version of EG that is registered.  If that's a difference between you, then one of you has 32-bit EG and one has 64-bit.

SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.
rasc42
Fluorite | Level 6

I just looked into my ProgramFiles(x86) folder and apparently there was a 32-bit SAS installation there (But it's not there anymore, the 32-bit Scripting dll doesn't even exist anymore). Is there a way to unregister this object? (I've tried deleting the registry keys, but apparently this is not the solution).

ChrisHemedinger
Community Manager

Going a bit off the beaten path here, but...

 

SEGScripting.dll (and most of EG, actually) is the same for 32-bit and 64-bit.  You *should* be able to unregister the 32-bit version of these by using regasm with the /u option (based on the command I supplied earlier).  However, make sure you run the 32-bit version of regasm.exe.  Actually, I might have steered you wrong with the command I supplied -- because I pointed you to /Framework and not /Framework64 for regasm,

 

So...maybe retry that regasm command:

 

  • "%windir%\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe" /codebase /tlb "C:\Program Files\SASHome\SASEnterpriseGuide\7.1\SASEGScripting.dll"
SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.
rasc42
Fluorite | Level 6

So I've tried (without the 64 after Framework, and with /u):

 

  • "%windir%\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" /u /codebase /tlb "C:\Program Files\SASHome\SASEnterpriseGuide\7.1\SASEGScripting.dll"

 

Then (with the 64, without /u):

 

  • "%windir%\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe" /codebase /tlb "C:\Program Files\SASHome\SASEnterpriseGuide\7.1\SASEGScripting.dll"

But I'm still getting the error. Tried restarting the PC, but nothing...considering that maybe a possible solution is just to ask the company to reinstall SAS on my PC (since I cannot do it myself)...which I'm not even sure will solve the problem.

 

It's just so bizarre, since everything seems correctly setup, it works with VBS, it works on my colleagues' PCs...

ChrisHemedinger
Community Manager

If it works with 64-bit VB Script, then I don't think it's the SAS Enterprise Guide install.  But...at this point I'm running low on ideas.

SAS Hackathon registration is open! Build your skills. Make connections. Enjoy creative freedom. Maybe change the world.
rasc42
Fluorite | Level 6

First of all, thanks so much for everything you've tried here with me,

 

So, my Python installation came from the Anaconda package (Which, in my colleagues' computer is not a problem at all). I've tried and

installed a fresh python installation, installed pywin32 and I managed to create the SAS object without problems. Do you have any idea why that may be?

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 15 replies
  • 4265 views
  • 2 likes
  • 2 in conversation