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
373 stars 150 forks source link

The system cannot find the file specified #346

Closed su35 closed 3 years ago

su35 commented 3 years ago

import saspy sas = saspy.SASsession()

Using SAS Config named: winlocal The OS Error was: The system cannot find the file specified

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

Attempted to run program C:\Program Files\SASHome\SASPrivateJavaRuntimeEnvironment\9.4\jrin\java.exe with the following parameters:['C:\Program Files\SASHome\SASPrivateJavaRuntimeEnvironment\9.4\jre\x08in\java.exe', '-classpath', 'C:\Users\Jun\anaconda3\lib\site-packages\saspy\java\saspyiom.jar;C:\Users\Jun\anaconda3\lib\site-packages\saspy\java\iomclient\log4j.jar;C:\Users\Jun\anaconda3\lib\ .......

KeyError Traceback (most recent call last)

in ----> 1 sas = saspy.SASsession() ~\anaconda3\lib\site-packages\saspy\sasbase.py in __init__(self, **kwargs) 535 # validate encoding 536 try: --> 537 self.pyenc = sas_encoding_mapping[self.sascei] 538 except KeyError: 539 print("Invalid response from SAS on inital submission. printing the SASLOG as diagnostic") KeyError: 'No SAS process attached. SAS process has terminated unexpectedly.' ----------------------------------------------- windows 10 SAS 9.4M6 last asapy ------------------------------------------------- sascfg_personal.py SAS_config_names=['winlocal'] winlocal = {'java' : 'C:\\Program Files\\SASHome\\SASPrivateJavaRuntimeEnvironment\\9.4\\jre\\bin\\java.exe', 'encoding' : 'windows-1252', } ----------------------------------------------- C:\Program Files\SASHome\SASFoundation\9.4>sas.exe/regserver C:\Program Files\SASHome\SASFoundation\9.4>path PATH=C:\Program Files (x86)\Common Files\Oracle\Java\javapath; ......... C:\Program Files\Java\jdk1.8.0_221\bin;C:\Program Files\Java\jdk1.8.0_221\jre\bin;D:\hive\b in;C:\Program Files\SASHome\SASFoundation\9.4\core\sasexe;C:\Program Files\SASHo me\SASFoundation\9.4\ets\sasexe;C:\Program Files\SASHome\Secure\ccme4;C:\Program Files\SASHome\SASFoundation\9.4\core\sasext;**C:\Program Files\SASHome\SASPrivate JavaRuntimeEnvironment\9.4\jre\bin**;C:\Users\Jun\AppData\Local\GitHubDesktop\bin; C:\Users\Jun\anaconda3\Scripts;C:\Program Files\SASHOME\SASFoundation\9.4\core\s asext
tomweber-sas commented 3 years ago

Hey @su35, that's an easy one. On windows you can't simply code single backslashes in file system paths, because python treats them as escape sequences when followed by a number of other characters. The error is that it can't find java, and that's because the path is wrong, because backslash b, and others turn into other characters, making the path wrong. So, either use double backslashes in your windows paths, or add the 'r' prefix to the string to make it not use backslashes as an escape character.

You can see the error with what youspecified: C:\Program Files\SASHome\SASPrivateJavaRuntimeEnvironment\9.4\jrin\java.exe C:\Program Files\SASHome\SASPrivateJavaRuntimeEnvironment\9.4\jr[e\b]in\java.exe See how the \b (backspace), removed the 'r' before it, as well as itself, leaving jrin instead of jre\bin?

#So, you can code either of these to fix this error in python:
winlocal = {'java' : r'C:\Program Files\SASHome\SASPrivateJavaRuntimeEnvironment\9.4\jre\bin\java.exe',

winlocal = {'java' : 'C:\\Program Files\\SASHome\\SASPrivateJavaRuntimeEnvironment\\9.4\\jre\\bin\\java.exe',

Tom

su35 commented 3 years ago

Thanks

tomweber-sas commented 3 years ago

Was that all that was wrong? Are you up and running?

tomweber-sas commented 3 years ago

I assume you've fixed that string and you're up and running. That's all that was needed for this error. If you have any other issue, just let me know! Thanks, Tom