0

I am trying below code :

sas = saspy.SASsession(cfgname='ssh', resutls='html',cfgfile='/Users/saumya.rb/opt/anaconda3/lib/python3.7/site-packages/saspy/sascfg.py')

error :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/saumya.rb/opt/anaconda3/lib/python3.7/site-packages/saspy/sasbase.py", line 415, in __init__
    self.sascfg            = SASconfig(**kwargs)
  File "/Users/saumya.rb/opt/anaconda3/lib/python3.7/site-packages/saspy/sasbase.py", line 130, in __init__
    SAScfg = self._find_config(cfg_override=kwargs.get('cfgfile'))
  File "/Users/saumya.rb/opt/anaconda3/lib/python3.7/site-packages/saspy/sasbase.py", line 267, in _find_config
    SAScfg = importlib.import_module(tempname)
  File "/Users/saumya.rb/opt/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 724, in exec_module
  File "<frozen importlib._bootstrap_external>", line 860, in get_code
  File "<frozen importlib._bootstrap_external>", line 791, in source_to_code
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/var/folders/pr/w_hplw1j7bl0vj2yj97_dd5mv3j_2t/T/tmp1bi7td8v/sascfg005.py", line 88
    'ssh'     : '/usr/bin/ssh',
              ^
SyntaxError: invalid syntax

please share me the details like which python version I should use. what should be my sascfg.py look like

I am using Python 3.7.4 (default, Aug 13 2019, 15:17:50) [Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin

using below config :

default  = {'saspath'  : '/sashome/compute/SASFoundation/9.4/sas'
            'ssh'      : '/usr/bin/ssh',
            'options'  : ["-fullstimer", "-autoexec", "/SAS9.4/SASConfig_bkp/compute/Lev1/SASApp/StoredProcessServer/autoexec.sas"],
            'autoexec' : "libname mylib '/ngs/app/sasp';",
            'host'     : 'remote.linux.host',
            'options'  : ["-fullstimer"]
            }


#ssh      = {'saspath' : '/opt/sasinside/SASHome/SASFoundation/9.4/bin/sas_en',
#            'ssh'     : '/usr/bin/ssh',
#            'host'    : 'remote.linux.host', 
#            'encoding': 'latin1',
#            'options' : ["-fullstimer"]
#            }
#
ssh      = {'saspath'  : '/sashome/compute/SASFoundation/9.4/sas'
            'ssh'      : '/usr/bin/ssh',
            'options'  : ["-fullstimer", "-autoexec", "/ngs/app/sasp/SAS9.4/SASConfig_bkp/compute/Lev1/SASApp/StoredProcessServer/autoexec.sas"],
            'autoexec' : "libname mylib '/ngs/app/sasp';",
            'host'     : 'remote.linux.host',
            'options'  : ["-fullstimer"]
            }
3
  • Show what you put into the saspy configuration file. Which method did you tell saspy to use to connect to SAS? Are you trying to shell into the Unix host and running command line SAS? Or do you have an application server that you connecting to which will launch a SAS session for you? Commented Mar 19, 2020 at 15:33
  • Added details for config file, not using any application server Commented Mar 19, 2020 at 18:19
  • Why do you have a SAS libname statement listed as the setting for autoexec? Why do you need that at all? Didn't you tell it the autoexec setting in options? Commented Mar 19, 2020 at 18:23

2 Answers 2

2

the error you got is because you're missing a comma between dictionary entries:

ssh = {'saspath' : '/sashome/compute/SASFoundation/9.4/sas' 'ssh' : '/usr/bin/ssh',

you need a comma after your path specification.

As for autoexec, the one listed in the options is for the remote SAS session to load and run, while the saspy autoexec is what saspy will submit for you after the session is up and connected to. So, these are two slightly different things.

Add in the comma and get rid of this syntax error and see what you get.

Thanks, Tom

Sign up to request clarification or add additional context in comments.

9 Comments

If saspy is using the second "autoexce" as code that its sends manually to SAS perhaps it would be better to name that parameter something else.
Another example of why I always place continuation characters, like the commas in that dictionary, at the beginning of the line. That way the human scanning the program can see them. If you place them at the end of the program lines then they are harder to see since the right edge is jagged. Even worse many times the lines are so long that the end of the line is out of the line of sight, or worse off the screen.
Thanks Tom ,let me check
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/opt/anaconda3/lib/python3.7/site-packages/saspy/sasbase.py", line 442, in init self._io = SASsessionSTDIO(sascfgname=self.sascfg.name, sb=self, **kwargs) File "/opt/anaconda3/lib/python3.7/site-packages/saspy/sasiostdio.py", line 205, in init self._startsas() File "opt/anaconda3/lib/python3.7/site-packages/saspy/sasiostdio.py", line 343, in _startsas rc = os.waitid(os.P_PID, self.pid, os.WEXITED | os.WNOHANG) AttributeError: module 'os' has no attribute 'waitid'
In retrospect, Tom, maybe the saspy key should be named autosubmit instead of autoexec.
|
0

Now addressing the errror recieved after fixing the syntax error. AttributeError: module 'os' has no attribute 'waitid' The STDIO access method uses this waitid method, but it isn't in the Mac version of Python. I reworked that access method to use waitpid instead of waitid and it resolved this problem, and now this access method works from a Mac client. Specifically, it's STDIO over SSH, as SAS doens't runn locally on a Mac. See saspy issue https://github.com/sassoftware/saspy/issues/288 for details about this fix.

This code is at master at the moment, but it will be in the next release I build; V3.3.5 Looking into one other issue to be sure it's not specific to the Mac. Will build this new release once that's addressed.

Saumya Ranjan, are you able to verify this fix?

Thanks, Tom

1 Comment

Just to tie this thread together, after fixing the syntax error then getting the error about no method named waitid, this problem was opened as an issue in saspy; where I will see that immediately (I have to remember to come search for saspy issues here). github.com/sassoftware/saspy/issues Another user also had this issue and added some info on that issue, and I was able to modify saspy to account for this missing method in MacOS version of python. They both verified this fixed the problem. Posting back here to close the loop. Oh, and that other problem is addressed too. Tom

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.