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
374 stars 149 forks source link

how to install SASPY #115

Closed maheshtalla closed 5 years ago

maheshtalla commented 6 years ago

Hi,

I'm new to python and I'm looking to install SASPY. As per the steps, its mentioned to install using pip, but is there a way we can download the tar file and install from it?. We as in organisation due to tightened security we don't have access to github/external sites from our server and not able to download and install it directly. So if you can help with precise steps to install manually that would help. Or is that if i just untar the file would suffice? FYI, I have already downloaded the latest tar file saspy-2.2.2.tar.gz. Thanks in advance for your help.

tomweber-sas commented 6 years ago

Yes, I can help with that! Wow, I only created 2.2.2 a few hours ago! So are you on linux? I'm guessing since you got the tar? Either way, yes extract that archive. What python do you have. I expect it has pip since that's how you install modules with python. Or is it anaconda and you use conda?

Assuming pip, you still install your local saspy directory (you un-tar'ed) using pip.

cd /wherever/you/untared/saspy
pip install .

or from any directory

pip install /wherever/you/untared/saspy/setup.py

That's all that takes. You still need to configure sascfg_personal.py so it knows how to connect to SAS. All of that is in the install/config doc, which you seem to be looking at.

Even if you're on windows, it's really the same. I guess in short, if you just say pip install saspy, it will try to download it, extract it and install it. If you already have it downloaded and extracted, then you just use pip to install it from where you have it locally.

Does that make sense? Tom

maheshtalla commented 6 years ago

Hi Tom, Thanks for your quick response. I'm using python 3.5.5 and it has pip. when I tried as you mentioned i'm getting below error. Not sure if it still trying to download. Can you please suggest. pip install setup.py Collecting setup.py Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(104, 'Connection reset by peer'))': /simple/setup-py/ Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(104, 'Connection reset by peer'))': /simple/setup-py/ Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(104, 'Connection reset by peer'))': /simple/setup-py/ Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(104, 'Connection reset by peer'))': /simple/setup-py/ Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(104, 'Connection reset by peer'))': /simple/setup-py/ Could not find a version that satisfies the requirement setup.py (from versions: ) No matching distribution found for setup.py

tomweber-sas commented 6 years ago

That looks like it is trying to download. Are you in the saspy directory when you issued pip install setup.py? It should look like (very similar) this:

drwxr-xr-x 6 sastpw r&d    4096 Mar 20 09:16 .
drwxr-xr-x 7 sastpw r&d    4096 Jan 29 12:39 ..
-rw-r--r-- 1 sastpw r&d    3074 Mar 20 09:16 CONTRIBUTING.md
-rw-r--r-- 1 sastpw r&d    2565 Mar 20 09:16 ContributorAgreement.txt
drwxr-xr-x 2 sastpw r&d    4096 Mar 20 09:16 dist
drwxr-xr-x 8 sastpw r&d    4096 Mar 20 09:16 .git
-rw-r--r-- 1 sastpw r&d     201 Mar 20 09:16 .gitignore
-rw-r--r-- 1 sastpw r&d       0 Mar 20 09:16 __init__.py
-rw-r--r-- 1 sastpw r&d      18 Mar 20 09:16 MANIFEST.in
-rw-r--r-- 1 sastpw r&d    1653 Mar 20 09:16 README.md
drwxr-xr-x 6 sastpw r&d    4096 Mar 20 09:48 saspy
drwxr-xr-x 2 sastpw r&d    4096 Mar  6 10:41 saspy.egg-info
-rw-r--r-- 1 sastpw r&d 2505441 Mar 20 09:16 saspy_example_github.ipynb
-rw-r--r-- 1 sastpw r&d    1558 Mar 20 09:16 setup.py
maheshtalla commented 6 years ago

Hi Tom,

Yes, exactly i'm in that directory and issued the pip install from there.

tomweber-sas commented 6 years ago

are you on windows or linux? try

pip install .

Can you show me the dir? That should just install the local code

tomweber-sas commented 6 years ago

yeah, it looks like there's actually a package names setup.py, or at least pip thinks so. Since you're in that directory, not qualifying setup.py with a path may have confused it. pip install ./setup.py or just pip install . would probably have worked

maheshtalla commented 6 years ago

Hi Tom, I'm using Linux, and below is the dir list and even just pip install didn't work. it says You must give at least one requirement to install (see "pip help install") saspy-2.2.2]$ ll total 2472 -rw-rw-r-- 1 bdsshdpadmin bdsshdpadmin 3074 Mar 20 12:56 CONTRIBUTING.md -rw-rw-r-- 1 bdsshdpadmin bdsshdpadmin 2565 Mar 20 12:56 ContributorAgreement.txt -rw-rw-r-- 1 bdsshdpadmin bdsshdpadmin 0 Mar 20 12:56 init.py -rw-rw-r-- 1 bdsshdpadmin bdsshdpadmin 18 Mar 20 12:56 MANIFEST.in -rw-rw-r-- 1 bdsshdpadmin bdsshdpadmin 1653 Mar 20 12:56 README.md drwxrwxr-x 6 bdsshdpadmin bdsshdpadmin 4096 Mar 20 19:02 saspy -rw-rw-r-- 1 bdsshdpadmin bdsshdpadmin 2505441 Mar 20 12:56 saspy_example_github.ipynb -rwxrw-r-- 1 bdsshdpadmin bdsshdpadmin 1558 Mar 20 12:56 setup.py

tomweber-sas commented 6 years ago

did you try

pip install .   # there's a period there

or 

pip install ./setup.py

or

pip install /wherever/you/untared/saspy-2.2.2/setup.py

Btw, I broke one thing in 2.2.2 and will be creating 2.2.3. Though it won't affect linux.

Tom

maheshtalla commented 6 years ago

I'm not sure, non of them working. [bdsshdpadmin@server saspy-2.2.2]$ pip install . Processing /OPT/saspy-2.2.2 Collecting pygments (from saspy==2.2.2) Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(104, 'Connection reset by peer'))': /simple/pygments/ Retrying (Retry(total=3, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(104, 'Connection reset by peer'))': /simple/pygments/ Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(104, 'Connection reset by peer'))': /simple/pygments/ Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(104, 'Connection reset by peer'))': /simple/pygments/ Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'ProtocolError('Connection aborted.', error(104, 'Connection reset by peer'))': /simple/pygments/ Could not find a version that satisfies the requirement pygments (from saspy==2.2.2) (from versions: ) No matching distribution found for pygments (from saspy==2.2.2) [bdsshdpadmin@server saspy-2.2.2]$ pip install ./setup.py Invalid requirement: './setup.py' It looks like a path. Does it exist ? [bdsshdpadmin@server saspy-2.2.2]$ pip install /OPT/saspy-2.2.2/setup.py Invalid requirement: '/OPT/saspy-2.2.2/setup.py' It looks like a path. Does it exist ?

tomweber-sas commented 6 years ago

Ok, that did work; you typed in the right command. However, saspy has a couple other requirements, which is now what it's trying to download. Looks like you need to download those and install them first. Sorry I didn't think of those. There's 2: install_requires = ['pygments', 'ipython>=4.0.0'],

However, they may then require others. Are you trying to use this in jupyter notbooks? If so it will nee the ipython. If not, we may be able to make it ignore that requirement. Can't see if it would have tried ipython since it can't get the pigments requirement, which also isn't really required if you're not using jupyter.

Do you know if you will be using that or if you have it installed?

You can issue

pip list

to see what you have installed.

Getting closer, Tom

maheshtalla commented 6 years ago

Im using python from linux it self, not using any interface. here are are the list from pip. Not sure to verify if installed SASPY as list doesn't show. pip list backports.ssl-match-hostname (3.4.0.2) blivet (0.61.15.65) Brlapi (0.6.0) chardet (2.2.1) configobj (4.7.2) coverage (3.6b3) cupshelpers (1.0) decorator (3.4.0) di (0.3) ethtool (0.8) firstboot (19.5) fros (1.0) iniparse (0.4) initial-setup (0.3.9.40) IPy (0.75) javapackages (1.0.0) kitchen (1.1.1) langtable (0.0.31) lxml (3.2.1) M2Crypto (0.21.1) Magic-file-extensions (0.2) mysql-connector-python (2.1.7) ntplib (0.3.2) pciutils (1.7.3) perf (0.1) pip (8.1.2) policycoreutils-default-encoding (0.1) pyasn1 (0.1.9) pycups (1.9.63) pycurl (7.19.0) pygobject (3.22.0) pygpgme (0.3) pyinotify (0.9.4) pykickstart (1.99.66.12) pyliblzma (0.5.3) pyOpenSSL (0.13.1) pyparsing (1.5.6) pyparted (3.9) pysmbc (1.0.13) python-augeas (0.5.0) python-dateutil (1.5) python-dmidecode (3.10.13) python-linux-procfs (0.4.9) python-meh (0.25.2) python-nss (0.16.0) pytz (2016.10) pyudev (0.15) pyxattr (0.5.1) redhat-access-insights (1.0.13) requests (2.6.0) rhnlib (2.5.65) rhsm (1.19.10) schedutils (0.4) seobject (0.1) sepolicy (1.1) setroubleshoot (1.1) setuptools (0.9.8) six (1.9.0) slip (0.4.0) slip.dbus (0.4.0) SSSDConfig (1.15.2) subscription-manager (1.17.15) urlgrabber (3.10) urllib3 (1.10.2) WALinuxAgent (2.2.18) yum-langpacks (0.4.2) yum-metadata-parser (1.1.4)

tomweber-sas commented 6 years ago

If that's the case then you don't need those requirements. You can edit the setup.py file and delete those two requirements from that dictionary. Change install_requires = ['pygments', 'ipython>=4.0.0'], To install_requires = [], Then do Pip install . Again.

Looks like that version of pip doesn't want the setup.py file name just the directory name.

Tom

tomweber-sas commented 6 years ago

So, I was just looking to remove those dependencies at master. saspy doesn't really require either. they're there for historical reasons. But, I see that just removing them from setup.py won't solve the problem. There are imports scattered through the code w/out try/catch such that it will install without them, but you won't be able to import saspy and run it. I will need to make a handful of changes to actually remove the dependency on ipython. It is only needed when you are running in jupyter, and you can't be running jupyter w/out ipython, so I don't need it as a dependency. I'll try to get this cleaned up and pushed to master tomorrow. Once that's done, if you get a new tar, extract it, and pip install it, you should then be able to use it. I would rather do that than make you try to pull down a bunch of unnecessary (in your case) dependencies. Are you just using saspy to run local linux SAS? That's what it sounds like.

Thanks! Tom

tomweber-sas commented 6 years ago

OK, well, I've been looking through this dependency web. The main saspy functionality doesn't need either of these. However, when you get to the analytics and results part, all of this is necessary and intertwined. To remove these as a dependency, requires conditionally importing not only them, but parts of saspy that are meant for returning graphs and such from analytic procs and formatting the SASLOG and things like that.

For the case where you're just trying to run outside of Jupyter, either line mode or batch (which I wrote this to do), you don't need any of that, and you can still get graphs and such, but not render them (batch mode); get them and write them out to file and render them in you're browser. This sounds like what you are trying to do.

I've created a new branch, noipython, to try to remove these dependencies. I can't test this out at the moment since I have all of these other modules installed. I'll have to create a new environment without any of this installed, like you have, to test. That's all fine, but I don't have that currently.

Are you willing to try this out, since you don't have any of these modules installed? You can download the saspy tarball from this test branch and we can see what happens. I don't mind creating a new environment and trying this out, but that will take more time.

I think I'd like to have a better idea of what you are trying to do with saspy in this environment, but I can see a reason for it to be like this, even if it isn't exactly what you're trying to do, so I think this is a worthwhile effort.

I think, so far, that the only restriction you'll have is that you won't be able to run with results'HTML' unless you are running in batch mode. You can run with results='text' or 'pandas', but with that you won't be able to run any of the analytics, as they produce graphs and plots and such, that can only come back in HTML (thus the need for batch mode in that case). That's where I would have to test this out to see what happens with these changes, but I don't have the environment at the moment.

Well, I'll catch up with you tomorrow on this. The Canes just lost a bad one to Edmonton and I'm going to bed :(

Thanks! Tom

maheshtalla commented 6 years ago

Hi Tom, As you mentioned earlier, i removed that dependency (install_requires = [])and tried installing which went fine and installed successfully. But you are correct it was not able to import after that and getting error as below. ImportError: No module named 'pygments' yes, i'm just using saspy on one linux and want to connect to SAS on other host. I mean both won't be on same host. I hope it should work. Sure we'll catch up tomorrow. Thanks for your support and have a good night.

tomweber-sas commented 6 years ago

That can, you need to do STDIO over SSH and that can work (it's Linux SAS right?). In the config doc. Yes, catch up in the AM.

Thanks! Tom

tomweber-sas commented 6 years ago

@maheshtalla just checking in to see if you've had a chance to try this and if you've had any luck. Thanks, Tom

maheshtalla commented 6 years ago

Hi @tomweber-sas, Thanks for followup, it was log time and lost track on this. Actually I have installed but was not able to import saspy after that and getting error as below. Can you please suggest. [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux Type "help", "copyright", "credits" or "license" for more information.

import saspy Traceback (most recent call last): File "", line 1, in ImportError: No module named 'saspy'

I have made changes in saspy.cfg accordingly to STDIO over SSH as per below. Please suggest if i'm missing something. default = {'saspath' : '/sso/sfw/sas/940/SASFoundation/9.4/bin/sas_u8' }

ssh = {'saspath' : '/sso/sfw/sas/940/SASFoundation/9.4/sas', 'ssh' : '/usr/bin/ssh', 'host' : 'xxxxxssast01.xxx.com', 'encoding': 'latin1', 'options' : ["-fullstimer"] }

tomweber-sas commented 6 years ago

The configuration definition, ssh=, appears reasonable. You've verified that you can passwordless ssh to that host? The error, however, is that it can't find saspy. That doesn't look like it's installed. Can you do

pip show saspy
maheshtalla commented 6 years ago

Yes, i have set passwordless ssh to the host. looks it is installed. below are the details of pip show saspy

Metadata-Version: 1.1 Name: saspy Version: 2.2.2 Summary: A Python interface to SAS Home-page: https://github.com/sassoftware/saspy Author: Tom Weber Author-email: Tom.Weber@sas.com License: UNKNOWN Location: /usr/lib/python2.7/site-packages Requires: Classifiers: Programming Language :: Python :: 3 Programming Language :: Python :: 3.4 Programming Language :: Python :: 3.5 Topic :: System :: Shells License :: OSI Approved :: Apache Software License

tomweber-sas commented 6 years ago

ok. I think we need to start fresh here. That shows it's installed, but says version 2.2.2. I had created a branch called noipython with the changes to get rid of the dependencies you don't have: ipython and pygments. But that branch shows V2.2.3, so I'm not sure you have the changes.

Also, V2.2.2 and 2.2.3 were broke; they aren't there anymore, and I think you got caught in the little window when they were there.

I've take these changes and created a new branch, built off master (v2.2.4): 'noipythonV2.2.4' Can you download that branch, uninstall what you have and then install this saspy and see if you can use this w/out the dependencies?

Thanks! Tom

maheshtalla commented 6 years ago

@tomweber-sas Can you please help setting up the initial configuration and connection. Parallely I was trying on Windows server also(installed anaconda with python and downloaded the SASPY) and i'm not able to import there as well and getting same kind of error.

tomweber-sas commented 6 years ago

Are you able to do a web-ex session if I send you a link? I think that would expedite this. If not, that's ok. On windows, can you do a normal pip install and have it get dependencies or is it the same issue w/ no internet access? Tom

jld23 commented 6 years ago

The path shoes r or was installed with Python 2 saspy needs Python 3


From: Tom Weber notifications@github.com Sent: Tuesday, April 24, 2018 3:32:43 PM To: sassoftware/saspy Cc: Subscribed Subject: Re: [sassoftware/saspy] how to install SASPY (#115)

Are you able to do a web-ex session if I send you a link? I think that would expedite this. If not, that's ok. On windows, can you do a normal pip install and have it get dependencies or is it the same issue w/ no internet access? Tom

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/sassoftware/saspy/issues/115#issuecomment-384052808, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADA5yw0yPVuqZG3obYquCjBNyXNFFKcbks5tr33bgaJpZM4Sydhk.

maheshtalla commented 6 years ago

@tomweber-sas Yes that's great and happy to have web-ex. I have sent a test mail from my mail ID, can you please share link. I hope its easy and resolve faster. @jld23 , I have installed Python3 as well and using that. some how its showing version 2 path.

Thanks a lot for your support.

tomweber-sas commented 6 years ago

I haven't gotten a direct email to reply to you, but here's the link. Wait, just got it. The links in the mail :)

maheshtalla commented 6 years ago

Hi @tomweber-sas You made my day. It was so helpful having Web-ex and resolving the issue. I appreciate it and thanks a ton.

venkattoluchuri commented 5 years ago

import saspy gives below error only from the jupyter notebook and it works on IDE Python.


ModuleNotFoundError Traceback (most recent call last)

in () ----> 1 import saspy ModuleNotFoundError: No module named 'saspy'
tomweber-sas commented 5 years ago

My guess is that you're not running the same python install from Jupyter as you are from whatever ide python you are using that has it installed. But that's the only guess I can make at this point.

If you submit the following from both jupyter and your other python, it might shed some light:

import sys
sys.path
Jayrrus commented 5 years ago

Hello Tom

I am am able to get everything installed but i am having problems getting a connection to SAS. I do have SAS installed on my Windows 10 laptop. I do have Anaconda installed and Jupyter running just fine. I was able to install sas on jupyter. However whenever I run import saspy sas = saspy.SASsession () sas I get this error: 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 javaC:\Program Files\SASHome\SASPrivateJavaRuntimeEnvironment\9.4\jrin\java.exe with the following parameters:['javaC:\Program Files\SASHome\SASPrivateJavaRuntimeEnvironment\9.4\jre\x08in\java.exe', '-classpath', 'C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94496prtxxsp01\deploywizprtxxsp01\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94496prtxxsp01\deploywiz\log4j.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94496prtxxsp01\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94496prtxxsp01\deploywiz\sas.core.jar;C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\saspyiom.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '57546', '-stdoutport', '57547', '-stderrport', '57548', '-zero', '-lrecl', '1048576', '']

If no OS Error above, try running the following command (where saspy is running) manually to see what is wrong: javaC:\Program Files\SASHome\SASPrivateJavaRuntimeEnvironment\9.4\jrin\java.exe -classpath "C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94496prtxxsp01\deploywizprtxxsp01\deploywiz\sas.svc.connection.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94496prtxxsp01\deploywiz\log4j.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94496prtxxsp01\deploywiz\sas.security.sspi.jar;C:\Program Files\SASHome\SASDeploymentManager\9.4\products\deploywiz94496prtxxsp01\deploywiz\sas.core.jar;C:\ProgramData\Anaconda3\Lib\site-packages\saspy\java\saspyiom.jar" pyiom.saspy2j -host localhost -stdinport 57546 -stdoutport 57547 -stderrport 57548 -zero -lrecl 1048576

Access Method = IOM SAS Config name = winlocal WORK Path = SAS Version = SASPy Version = 2.4.3 Teach me SAS = False Batch = False Results = Pandas SAS Session Encoding = Python Encoding value = windows-1252 SAS process Pid value = None

I am new to python. What am i doing wrong? I have followed nearly every manual on how to install and establish a proper connection with SAS but my brain is at it wits end.

Please help Tom. Thanks.

venkattoluchuri commented 5 years ago

Hello Tom, My issue got resolved. I need to import saspy to anacode location too in order to import saspy from jupytor notebook.

Can you put some light on how to use get benefit of SAS Grid process for SASPy

tomweber-sas commented 5 years ago

Hey @venkattoluchuri , you got past the following eror:

The OS Error was: The system cannot find the file specified

That was that it couldn't find your java command that was in your winlocal configuration definition.

SAS Grid, is mostly just remote IOM connection, though there are a few extra things you can take advantage of. Grid has the capability of having HA (High Availability) Object Spawners, such that if one goes down, there are others available to continue to launch servers for jobs. saspy supports this by allowing the List of object spawners on the 'iomhost' key in your configuration definition. If it can't make a connection to the first in the list, it trys each of the rest until it succeeds or they all fail.

iomhost -
(Required) The resolvable host name, or IP address to the IOM object spawner. New in 2.1.6; this can be a list of all the object spawners hosts if you have load balanced object spawners. This provides Grid HA (High Availability)

Another feature for Grid that saspy supports is the ability to direct saspy work to specific work queues. See this part of the doc for that: https://sassoftware.github.io/saspy/advanced-topics.html#configuring-grid-option-sets-to-have-saspy-run-on-a-specific-queue

Also, not necessarily specific to Grid, but any remote IOM configured for it is the ability to disconnect from a workspace server and reconnect to that same workspace later (w/in the timeoput window configured in metadata). See https://sassoftware.github.io/saspy/advanced-topics.html#disconnecting-from-an-iom-session-and-reconnecting-back-to-it for that.

Thanks! Tom

tomweber-sas commented 5 years ago

Oh, sorry @Jayrrus I didn't see there were multiple people on this thread. In my previous post, you will see that the error you have is that java.exe is not found. Depending on how you install java, it may configure itself into your system path so that just saying 'java' works, but it may not. You can just specify the full path in your configuration definition to address this.

java -
(Required) The path to the Java executable to use. For Linux, use a fully qualifed path. On Windows, you might be able to simply enter java. If that is not successful, enter the fully qualified path.

Also, it may be beneficial to open a new issue for these so that each has it's own specific thread.

Thanks! Tom

tomweber-sas commented 5 years ago

Cleaning up. I see this was resolved and the other issue we switched to was also resolved. So, closing this issue. If there are any other problems, just open a new issue to track them. Thanks! Tom