Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAS kernel does not work on Juypter - local host #93

Closed
TomMeowMeow opened this issue Jan 25, 2018 · 49 comments
Closed

SAS kernel does not work on Juypter - local host #93

TomMeowMeow opened this issue Jan 25, 2018 · 49 comments

Comments

@TomMeowMeow
Copy link

I tried so hard to make the juypter talk to SAS. However, I failed in the last step. Can anyone help me with it. The R kernel and Python kernel works fine on Juypter. The error is:

The application could not log on to the server. The server process did not start.
SAS process has terminated unexpectedly. RC from wait was: 4294967290
SAS Connection failed. No connection established. Double check you settings in sascfg.py file.

Full error screenshot enter image description here

This is my setting in the sascfg.py

cpW = "D:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94250__prt__xx__sp0__1\deploywiz\sas.svc.connection.jar"
cpW += ";D:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94250__prt__xx__sp0__1\deploywiz\log4j.jar"
cpW += ";D:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94250__prt__xx__sp0__1\deploywiz\sas.security.sspi.jar"
cpW += ";D:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz__94250__prt__xx__sp0__1\deploywiz\sas.core.jar"
cpW += ";D:\ProgramData\Miniconda3\Lib\site-packages\saspy\java\saspyiom.jar"

winlocal = {'java' : 'java',
'encoding' : 'windows-1252',
'classpath' : cpW
}

Same question I have posed on stackoverflow:
https://stackoverflow.com/questions/48399232/sas-kernel-does-not-work-on-juypter

@tomweber-sas
Copy link
Contributor

Ok, so in a python kernel, can you successfully run the following? Can you show the code and results.

import saspy
sas = saspy.SASsession(cfgname='winlocal')
sas
cars = sas.sasdata('cars', 'sashelp')
cars.head()

Also, do you have the path to the sspiauth.dll in your System Path? Can you confirm that?

Thanks,
Tom

@TomMeowMeow
Copy link
Author

Hi tomweber,

Thanks very much for reply and attention.

In python kerner, the sas cannot run. see the description below. I also attached the PDF file.

sspiauth.dll is in my system path. I double checked the system variable, and try to make sure the command pump can access the file. See the picture in file

sspiauth dll
.

Error message in python kernel.pdf

:

`The application could not log on to the server. The server process did not start.
SAS process has terminated unexpectedly. RC from wait was: 4294967290
SAS Connection failed. No connection established. Double check you settings in sascfg.py file.

Attempted to run program java with the following parameters:['java', '-classpath', 'D:/Program Files/SASHome/SASDeploymentManager/9.4/products/deploywiz__94250__prt__xx__sp0__1/deploywiz/sas.svc.connection.jar;D:/Program Files/SASHome/SASDeploymentManager/9.4/products/deploywiz__94250__prt__xx__sp0__1/deploywiz/log4j.jar;D:/Program Files/SASHome/SASDeploymentManager/9.4/products/deploywiz__94250__prt__xx__sp0__1/deploywiz/sas.security.sspi.jar;D:/Program Files/SASHome/SASDeploymentManager/9.4/products/deploywiz__94250__prt__xx__sp0__1/deploywiz/sas.core.jar;D:/ProgramData/Miniconda3/Lib/site-packages/saspy/java/saspyiom.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '64810', '-stdoutport', '64811', '-stderrport', '64812', '-zero', '']

Be sure the path to sspiauth.dll is in your System PATH

No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.
No SAS process attached. SAS process has terminated unexpectedly.

ValueError Traceback (most recent call last)
in ()
2 sas = saspy.SASsession(cfgname='winlocal')
3 sas
----> 4 cars = sas.sasdata('cars', 'sashelp')
5 cars.head()

d:\programdata\miniconda3\lib\site-packages\saspy\sasbase.py in sasdata(self, table, libref, results, dsopts)
505 results = self.results
506 sd = SASdata(self, libref, table, results, dsopts)
--> 507 if not self.exist(sd.table, sd.libref):
508 if not self.batch:
509 print(

d:\programdata\miniconda3\lib\site-packages\saspy\sasbase.py in exist(self, table, libref)
397 :rtype: bool
398 """
--> 399 return self._io.exist(table, libref)
400
401 def sasets(self) -> 'SASets':

d:\programdata\miniconda3\lib\site-packages\saspy\sasioiom.py in exist(self, table, libref)
982 l2 = ll['LOG'].rpartition("TABLE_EXISTS= ")
983 l2 = l2[2].partition("\n")
--> 984 exists = int(l2[0])
985
986 return exists

ValueError: invalid literal for int() with base 10: 'No SAS process attached. SAS process has terminated unexpectedly.'`

Best regards
Tom

@tomweber-sas
Copy link
Contributor

Ok, thanks, so this isn't really a sas_kernel issue, saspy can't connect to your SAS yet, so we have to start there. What SAS do you have installed? Is it Base SAS or just a client, like EG? I've ggoled the error message, as that's not one I've seen before. Most issues I see are all with clients trying to connect to a remote IOM server of some kind.
Thsi Local connection type is to connect to a Base SAS deployment. If what you have in D:... isn't at least a Base SAS deployment, that would certainly be a problem. Do you have sas.exe in there?
BTW, which version of saspy do you have? Didn't get that in the ouput; submitting 'sas' would have printed out info, but sine the sasdata() was in the same cell, Jupyter didn't get that output written.

Thanks,
Tom

@TomMeowMeow
Copy link
Author

Hi tomweber,

Thanks very much for help me this.

What SAS do you have installed?

 I installed SAS 9.4 and it's not just a client. More specifically

sas

 Do you have sas.exe in there?
 Yes I did. Actually, the local SAS runs pretty well. I have used it and it's completely fine. 

 which version of saspy do you have?
 The version I use is below:
 SAS-kernel==2.1.7
 saspy==2.2.1

 I also re-run the code you sent me before, and here is the result:

123

My suspicious:
   Would you think this could be due to some reasons of Java? 
   I am thinking this might be due to the fact that java cannot open SAS file correctly? 
   However, I don't konw how to test this, 
   I am actually a statistic programmer, I am heavy lack of knowledge of other language. 

Thanks for your help.

Best regards
Tom

@tomweber-sas
Copy link
Contributor

Ok, so that looks like it should be able to work then. I haven't seen this error before. What version of java do you have? I don't see anything here to make me suspicious of java though.
I wonder if it could be a permission thing? I take it you're only running with your id in all cases? Running SAS itself and saspy; well, actually, you're running jupyter, are you starting it us w/ your id, or is it running with some other permissions???
Can you just bring up a dos shell and run python natively (what version of pythong BTW?) and submit the import, sassession; sas and see what we get?
I'll have to dig in here some too to see how this error could happen with base SAS.

We'll get it figured out!
Thanks,
Tom

@TomMeowMeow
Copy link
Author

What version of java do you have?
I am using version 8 update 161.
111

I take it you're only running with your id in all cases?
Yes, lucky for me. I am allowed to use my personal PC in my work. I am the administrator of the laptop, and there is no such thing about other admistrator account or control. You can regard the computer as a pure personal PC.

Running SAS itself, jupyter and saspy.
The way I run SAS is simple click SAS.exe. then there would a user panel control and ask me to click yes.
The way I run jupyter is simple using "jupyter notebook" in comman prompt. See the picture below, poten is my ID. I do not need to imput my id to run the jupyter in the command line, or should I try using it?
222

Can you just bring up a dos shell and run python natively (what version of pythong BTW?) and submit the import, sassession; sas and see what we get?
My python version is 3.6.3
Unfortunately, it still fails. see the picture below:
3333

The reason I am suspicious about Java,
I tried edit the absolute path for java and change it back. Everytime I change the java path and run SAS code in Jupyter, it would take some time. Then there would be a network access permission pop out, and ask me to agree. I agreed every time, but the SAS still fails. This is the reason I suspect Java.

Thanks for help. I actully also googled the whole website, and haven't found anyone has the similar problem as me. I am kind of desperate, I am so glad you can see this.

Best regards
Yan

@tomweber-sas
Copy link
Contributor

So, I don't see anything out of the ordinary w/ your java, SAS, python, saspy or saspy config. This all should just be working. So, there's got to be something unusual about your environment. I'm checking w/ IOM folks here about how you could be getting this error trying to make a local connection. And, the network pop up you're getting is also a suspicious clue too. I don't suspect java itself. This is a personal machine on your corporate network? And the fact that this error only 'seems' (don't know enough yet) to be associated with remote IOM connections, if odd. This 'should' all just be localhost, but there seems to be something else going on here.

Ok, got an idea from one of our guys. So, in the windows registry is the command to start SAS for this local IOM connection I'm trying to do. I've seen a problem a few times where a user doesn't have this in their registry and they get this error:
The application could not find a command to launch a SAS Workspace Server.

In the troubleshooting section of the doc, this is documented with the workaround. This isn't what you're getting, but the thought is, if you have a valid command there that is being used, but it isn't (effectively) sas.exe, but rather something that is trying to access something else (remote connection), then maybe that could be why you're getting some network issue and an error that seems to be associated w/ a remote connection to somewhere.

So, lets try the following and see what happens. Add the following key to your winlocal config definition and edit the correct path to your sas.exe, then give it a try again; python shell (less other pieces for now).
This will override whatever might be in the registry and should start your local SAS.

'javaparms' : ['-Dcom.sas.iom.orb.brg.zeroConfigWorkspaceServer.sascmd=C:\PROGRA~1\SASHome\SASFOU~1\9.4\SAS.EXE']

I'll track down what the key is in the registry so we can look to see what's there too.

@TomMeowMeow
Copy link
Author

Hi tomweber,

Thanks for reply.

Now it seems something wrong here, because I cannot load saspy. see what happend in picture
1
in my winlocal config:
2

Jupytor also says the SAS kernel is dead and can't be restart.

Any further advice? or am I mistaken on something here.

Best regards
Tom

@tomweber-sas
Copy link
Contributor

you need to add a ',' comma in your config definition to the line above this. That;s all.

@tomweber-sas
Copy link
Contributor

Also, just in case. every example, and in my own install, the path they use is always the goofy ~ 8char windows paths (to remove spaces from w/in the path which half the system can't handle on windows), so unless this just works, you might want to try the ~ version.

'javaparms' : ['-Dcom.sas.iom.orb.brg.zeroConfigWorkspaceServer.sascmd=D:\PROGRA~1\SASHome\SASFOU~1\9.4\SAS.EXE']

@TomMeowMeow
Copy link
Author

Hi tomweber,

Thanks for reply. I corrected the code and also tried the ~ version.

It still mentions fail like before
000000

any clue ?

Best regards
Tom

@tomweber-sas
Copy link
Contributor

I tracked down the registry key. it's
HKEY_CLASSES_ROOT\CLSID{440196D4-90F0-11D0-9F41-00A024BB830C}\LocalServer32
Can you see what you have there?
you can use 'regedit' to nevigate to the key and see the value.

@TomMeowMeow
Copy link
Author

yes, I have something here
33333333333

The value name is
D:\PROGRA2\SASHome\SASFOU1\9.4\SAS.EXE -config "D:\Program Files\SASHome\SASFoundation\9.4\sasv9.cfg" -objectserver -nologo -noterminal -noprngetlist

@tomweber-sas
Copy link
Contributor

well, that looks correct. D: is a physical drive on your PC, right? Not a mounted drive (network)?
Just checking. I'm not seeing any reason for this error. Is there anything else you can think of that might be relevant? I'm at a loss.

@TomMeowMeow
Copy link
Author

Hi tomweber,

Yes, D: is a physical driver on my PC.
I am thinking about I install Anaconda and miniconda at the same time, and saspy is in miniconda, but Python is in Anaconda. Could this screw something in there?

Thanks for your help.

Best regards
Tom

@TomMeowMeow
Copy link
Author

Hi tomweber,

You might be off from work just like me. I would like to add last piece of information.

You mentioned before it is suspicious I need to allow the Java to access the network when I first load saspy. Since the session is only a local windows session, why the java need to access the permission to connect to public or private network ? This might be a clue? Also, I am using education network for now. I will give a shot when I am back to apartment.

Thanks for all the help so far. Have a good day.

Best regards
Tom

@TomMeowMeow
Copy link
Author

Hi tomweber,

I found that the windows defender would ask permission for java to connect network. I disabled the windows defender, however it is still not wokring. Now I suspect the problem might be something in localhost.
1234

@tomweber-sas
Copy link
Contributor

Well, that's fingers in the pie. How about trying this. Cut-n-paste the command from your windows registry and run that from a dos shell to see what happens. Change the -noterminal to -terminal (just delete the 'no') and it should pop up a window with the log. Like this:
image

@TomMeowMeow
Copy link
Author

Hi tomweber,

I am so glad you are still online.

I tried. However, I did not get any window pops out. There is no log or message comes out. It is just the fail information as before.

Best regards
Tom

@TomMeowMeow
Copy link
Author

Since the key is sas.py. I decide to upload it here, so you may see anything I missed. I changed it to txt since github does not support .py file

sascfg.txt

@tomweber-sas
Copy link
Contributor

any chance you can connet up with a webX to look at this in deatil?

@tomweber-sas
Copy link
Contributor

I'm not convinces that the path in javaparms is ok; windows doesn't work well with blanks in the path.
'javaparms' : ['-Dcom.sas.iom.orb.brg.zeroConfigWorkspaceServer.sascmd=D:/Program Files/SASHome/SASFoundation/9.4/SAS.EXE']

Can I see the dos windo with output from running the command from your registry key, and how about running it using the path above: D:/Program Files/SASHome/SASFoundation/9.4/SAS.EXE

Here's one more way to try running it, from powershell:
param([string]$code)
$wks = new-object -comobject SAS.Workspace
$lang=$wks.LanguageService
$lang.Submit($code)
$cc=[int[]]@()
$type=[int[]]@()
$line=[string[]]@()
$lang.FlushLogLines(1024, [ref]$cc, [ref]$type, [ref]$line)
$line
$output = $lang.FlushList(2048)
$output
$wks.close()

what does that show?

@TomMeowMeow
Copy link
Author

Hi tomweber,

Sorry, I do not understand what webX is. I apology for my poor knoweledge.

I changed the path as you mentioned, however still same error message
1212

I have no idea why I can't run the other way
321

@tomweber-sas
Copy link
Contributor

Hey, webX is a way we can share screens so we can look at this together. It's just over the internet connection to make it easier to look at this at the same time.

That last thing needs to be run in powershell, not a DOS cmd prompt. But I still don't see running the command in the DOS shell.

If you can email me, I can send you a invite to a webX session. If not, we can keep working like this of course.

@TomMeowMeow
Copy link
Author

It seems powershell still does not accept it.
2222222

@tomweber-sas
Copy link
Contributor

ok, and can I see what happens when you try to run the sas command from a DOS shell:

D:\PROGRA2\SASHome\SASFOU1\9.4\SAS.EXE -config "D:\Program Files\SASHome\SASFoundation\9.4\sasv9.cfg" -objectserver -nologo -terminal -noprngetlist

I would cut-n-paste this out of your registry itself, not from above. I don't think my cut-n-paste from your post of this is right.

@TomMeowMeow
Copy link
Author

Sorry, I forget to include this.
SAS seems to start succefully?
3344

@tomweber-sas
Copy link
Contributor

Ah, well that worked. Does it work also from DOS? I'll have to get some folks here to look at this and see what they think.

@TomMeowMeow
Copy link
Author

3434343434
Yes, it works in dos.

@TomMeowMeow
Copy link
Author

HI tomweber,

Thanks very much so far. My remote server also has python, sas and jupyter. I would try to install saspy there, and see what would happen there.

In this case, I might be able to query my local IT staff members. I'll get back to you if I get any luck.

Best regards
Tom

@tomweber-sas
Copy link
Contributor

ok, well that's good then. There's something else we're missing that's interfering with this somehow then.
Can you look in the Windows event viewer and see if there are any messages that have to do with this? You might want to bring that up and then run a case so you can see if anything shows up then, note the time for the timestamps. Maybe there's an error in there that will clue us in. maybe some other antivirus or firewall or who knows when on the system, is keeping this from working. Like that defender thing with the network.

@TomMeowMeow
Copy link
Author

Hi tomweber,

Thanks. I run the case and checked the windows event viewer. Unfortunately, nothing suspecious were found. I only have windows firewall and it is closed. The other thing I have is a CCcleaner. I do not have other anti-virus software. There is no action needed in windows firewall as well. This seems to become a mysterious now.

@tomweber-sas
Copy link
Contributor

for the powershell case, I was told you probably need to open powershell 'as administrator', that should 'elevate permissions' and get that case to run. And the same windows guy that gave me that thinks it still might be an issue with the paths in the commands. They've seen issues with that after updates.

I've been playing around with the command in javaparms myself. When the path isn't good, I do see the same error you are seeing! That's good, actually. I've bee successful running with this (what's in my registry key):

         'javaparms' : ['-Dcom.sas.iom.orb.brg.zeroConfigWorkspaceServer.sascmd="C:\PROGRA~1\SASHome\SASFOU~1\9.4\SAS.EXE" -config "C:\PROGRA~1\SASHome\SASFOU~1\9.4\sasv9.cfg" -objectserver -nologo -noterminal -noprngetlist']

Can you try using this (changed only to get your paths correct), which I think would be this, but double check:

         'javaparms' : ['-Dcom.sas.iom.orb.brg.zeroConfigWorkspaceServer.sascmd="D:\PROGRA~2\SASHome\SASFOU~1\9.4\SAS.EXE" -config "D:\PROGRA~2\SASHome\SASFOU~1\9.4\sasv9.cfg" -objectserver -nologo -noterminal -noprngetlist']

See if that works with your saspy case. You can try it from a DOS shell to be sure it's typed in right:
"D:\PROGRA2\SASHome\SASFOU1\9.4\SAS.EXE" -config "D:\PROGRA2\SASHome\SASFOU1\9.4\sasv9.cfg" -objectserver -nologo -terminal -noprngetlist

I hope that works.

@tomweber-sas
Copy link
Contributor

"D:\PROGRA~2\SASHome\SASFOU~1\9.4\SAS.EXE" -config "D:\PROGRA~2\SASHome\SASFOU~1\9.4\sasv9.cfg" -objectserver -nologo -noterminal -noprngetlist

@tomweber-sas
Copy link
Contributor

That (with my paths) worked from DOS, as it does for you, but it also worked from saspy too. It failed with your same error, from saspy, when I didn't have the quotes right or the path wasn't right. So it might just be something with these silly paths in windows. We have a defect open about getting these command paths right in the registry, so it may be something about that tripping it up here.

@TomMeowMeow
Copy link
Author

444444
OMG, you are genius
It seems work now.

@TomMeowMeow
Copy link
Author

66666
Jupyter works as well. Excellent work !!!!

@tomweber-sas
Copy link
Contributor

If I were genius I'd know what's wrong :)
But, lets try re-regestering your sas command and comment out the javaparms and see if it get's fixed for real.

Apparently that is done by running sas with this option '/regserver'. Like this
sas.exe /regserver

So,
D:...\sas.exe /regserver

Run that then comment out javaparms then run fresh python and try saspy

@tomweber-sas
Copy link
Contributor

yes, if saspy works, then sas_kernel and jupyter all will work!

@TomMeowMeow
Copy link
Author

Sorry, I am little lost here. What do I need to run and where?
Also you are right, if I don't choose the administrtor for my CMD then it would not work as well.

@tomweber-sas
Copy link
Contributor

Ah, from DOS, just run sas.exe /regserver
You might need to fully qualify sas.exe - D:\bla bla\sas.exe /regserver
This should update the command in the refistry key; look and see if it's different after.
Then comment out the javaparms in your saspy config and see if everything works like it should.
Show me what the new key is, also.

@TomMeowMeow
Copy link
Author

DOS can't read the file path ?

C:\Users\poten
λ D:\Program Files\SASHome\SASFoundation\9.4\SAS.EXE/regserver
'D:\Program' is not recognized as an internal or external command,
operable program or batch file.

@tomweber-sas
Copy link
Contributor

of course not, it can't handle blanks in path names! Put quotes aroune the entire "D:...\sas.exe" /regsrever
or use

D:\PROGRA~2\SASHome\SASFOU~1\9.4\SAS.EXE /regserver

@TomMeowMeow
Copy link
Author

The new register key is:
D:\PROGRA2\SASHome\SASFOU1\9.4\SAS.EXE -config "D:\PROGRA2\SASHome\SASFOU1\9.4\sasv9.cfg" -objectserver -nologo -noterminal -noprngetlist
It's different from the old one.
I think
sascfg.txt
you are right. It's the problem of the path of the register key. Now it's worked completely. Please accept the fact that you are genius. :)
So in summary the solution is:

  1. fix the path in register key
  2. Run CMD as the admin otherwise it would give the same error as above.
    Thank you very much !!
    56565656
    123321

@TomMeowMeow
Copy link
Author

I also guess only poor guys like me who installed SAS on other disks rather than C disk would have this problem?

@tomweber-sas
Copy link
Contributor

Man alive! We'll I've learned something new today, so I think I'll quit while I'm ahead! :) :)
I'm so glad we got to the bottom of this and you're up and running.
I will add this info to the troubleshooting section of the doc, so it's there for other too!

Thanks!
Tom

@TomMeowMeow
Copy link
Author

Hey tomweber,

Yes, I totally agree. I learned a lot of things from this process. Thanks for helping !! Have a good night.

Best regards
Tom

@tomweber-sas
Copy link
Contributor

I don't think so, I think something changed about these goofy paths and quotes and things with windows. We have a defect about something having to do with that. That's where I got the /regserver from one of our windows guys. He knew about there being a path issue.
Yes, have a good night and let me know if there is anything else as you start to use saspy and sas_kernel!
Tom

@tomweber-sas
Copy link
Contributor

Ok, I've added this to the troubleshooting guide. It's under IOM, in the part with the various IOM Errors, number 5. I will go ahead and close this. If you need to reopen for any reason, no problem. If you run into anything else, just open another issue!

Thanks,
Tom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants