sassoftware / saspy

A Python interface module to the SAS System. It works with Linux, Windows, and Mainframe SAS as well as with SAS in Viya.
https://sassoftware.github.io/saspy
Other
366 stars 149 forks source link

Permission denied running saspy with Windows (IOM, local) #544

Closed bauerandrew closed 1 year ago

bauerandrew commented 1 year ago

Hello, I'm having trouble getting saspy to connect to SAS. I'm running saspy from an Anaconda install on Windows (Python 3.9 through Spyder), and I have SAS 9.4 installed locally.

My command is: sas = saspy.SASsession(cfgname='winlocal', java='C:\\Program Files\\Java')

My specific error message is: `The OS Error was: Access is denied

SAS Connection failed. No connection established. Double check your settings in sascfg_personal.py file.

Attempted to run program C:\Program Files\Java with the following parameters:['C:\Program Files\Java', '-classpath', 'C:\Anaconda3\lib\site-packages\saspy\java\saspyiom.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\log4j.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sas.security.sspi.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sas.core.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sas.svc.connection.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sas.rutil.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sas.rutil.nls.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sastpj.rutil.jar;C:\Anaconda3\lib\site-packages\saspy\java\thirdparty\glassfish-corba-internal-api.jar;C:\Anaconda3\lib\site-packages\saspy\java\thirdparty\glassfish-corba-omgapi.jar;C:\Anaconda3\lib\site-packages\saspy\java\thirdparty\glassfish-corba-orb.jar;C:\Anaconda3\lib\site-packages\saspy\java\thirdparty\pfl-basic.jar;C:\Anaconda3\lib\site-packages\saspy\java\thirdparty\pfl-tf.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '56146', '-stdoutport', '56147', '-stderrport', '56148', '-zero', '-lrecl', '1048576', '']

If no OS Error above, try running the following command (where saspy is running) manually to see what is wrong: C:\Program Files\Java -classpath "C:\Anaconda3\lib\site-packages\saspy\java\saspyiom.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\log4j.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sas.security.sspi.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sas.core.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sas.svc.connection.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sas.rutil.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sas.rutil.nls.jar;C:\Anaconda3\lib\site-packages\saspy\java\iomclient\sastpj.rutil.jar;C:\Anaconda3\lib\site-packages\saspy\java\thirdparty\glassfish-corba-internal-api.jar;C:\Anaconda3\lib\site-packages\saspy\java\thirdparty\glassfish-corba-omgapi.jar;C:\Anaconda3\lib\site-packages\saspy\java\thirdparty\glassfish-corba-orb.jar;C:\Anaconda3\lib\site-packages\saspy\java\thirdparty\pfl-basic.jar;C:\Anaconda3\lib\site-packages\saspy\java\thirdparty\pfl-tf.jar" pyiom.saspy2j -host localhost -stdinport 56146 -stdoutport 56147 -stderrport 56148 -zero -lrecl 1048576

No SAS process attached. SAS process has terminated unexpectedly. Invalid response from SAS on inital submission. printing the SASLOG as diagnostic

Traceback (most recent call last):

File "C:\Users\ambauer\AppData\Local\Temp/ipykernel_13296/754549713.py", line 3, in sas = saspy.SASsession(cfgname='winlocal', java='C:\Program Files\Java')

File "C:\Anaconda3\lib\site-packages\saspy\sasbase.py", line 567, in init self.pyenc = sas_encoding_mapping[self.sascei]

KeyError: 'No SAS process attached. SAS process has terminated unexpectedly.'`

I think the problem may be that I missed an opportunity to have my OS allow permissions for Python/Spyder to speak to SAS - the Administrator window popped up asking if I wanted to allow, and I accidently click deny rather than allow. I can't seem to get Windows to prompt me again to allow permissions; each time I rerun the command, no prompt is requested.

So this may be an easier, non-saspy answer, but I can't seem to find help online telling me how to allow an administrator prompt after initially denying.

Thank you,

Andrew

tomweber-sas commented 1 year ago

Hey, that's a new on on me. I haven't seen that error before, but I understand that's it's probably from that pop up. That was a Windows thing, not a SAS thing, right? Or some other kinds of third party anivirus application or something? I'm expecting so. Is this a company machine? Would your IT know what it was and how to reset it?

bauerandrew commented 1 year ago

Thanks for the response. Yes, I think it was a standard Windows thing - seemed like a typical thing. Here's a screenshot of something similar (generic from the web, not from my machine).

[image

If it's new to you, I'll try and see what IT thinks. I thought it should be an easy reset, surprised I haven't found help online yet. Thanks again for the response and suggestions.

Andrew

tomweber-sas commented 1 year ago

It was a User Account Control pop up? Then yes, you ought to check w/ your IT to see how to fix this. There's a million hits on UAC, though half are for window 8, which no one would be using still, and most don't address resetting a given application; just setting the level for the prompting. Having no idea what's on your system, I'm gonna let you check w/ your admins to see what the right way to reset that is. Out of curiosity, can you still double click a .sas program and have SAS come up?

bauerandrew commented 1 year ago

I'll see if admin can give an answer, and can update to close this discussion if they do. And yes, I can still open SAS no problem (and no UAC prompts) - either clicking the app or clicking an existing program.

I wish I didn't move too quickly to decline the UAC request when I ran the sas = saspy.SASsession(cfgname='winlocal', java='C:\\Program Files\\Java') command so I could recall which specific program was asking for permission (Java? SAS? Spyder?). Maybe if admin can't help me out (or Google), I could reinstall saspy and Java and see if the UAC prompt returns.

tomweber-sas commented 1 year ago

Yeah, I gotcha. I'm not sure what app it thought it was trying to get permission on. Good that you can still start up SAS. Can you try connecting with saspy from a command prompt instead of spyder; line mode python (mybe you have to use anaconda prompt, not a dos shell)? that may trigger a different path. Just thinking of things to try. If you know which thing it was asking about, you're idea of reinstalling might happen to retrigger the prompt. I just don't know with windows; no telling. Hopefully your admin folks know what this is and how to fix it.

bauerandrew commented 1 year ago

Call this one resolved - and I think Java was the culprit. I reinstalled it, effectively reset the Java path to default (because "C:\Program Files\Java" was still saying permission denied, I re-entered the command as sas = saspy.SASsession(cfgname='winlocal'), and was prompted by UAC to give permission to Java. The SAS connection was thus established, and I'm now good to go. All through Spyder.

Thanks again for all the replies.

tomweber-sas commented 1 year ago

Hey that's great! Anytime you can defeat Windows at it's nonsense, I call it a good day! :) Glad you're up and running. I'll close this. Let me know if you need anything else! Tom