BookmarkSubscribeRSS Feed
sumandas1982
Calcite | Level 5

Hi SAS Community,

 

I am trying to run some Python code in SAS Viya platform. But the server has multiple Python installed ( 2.6 and 3.6 version). When I am running the python code from SAS Studio, Viya is connecting to Python 2.6 interpreter. But when I run the python code from terminal server command prompt, 3.6 python interpreter has been used. I am trying to change the configuration in Viya, so that SAS will use the 3.6 python interpreter instead of 2.6. It will be great if someone can put some light on this issue if they have ever faced this issue?

 

This is the server details -

Current version: V.03.05M0P110619
Expiration:   21JAN2021.
Grace Period:  45 days (ending 07MAR2021).
Warning Period: 45 days (ending 21APR2021).
System birthday:   15JAN2020.
Operating System:   LIN X64

 

Thanks in advance.

Suman

6 REPLIES 6
alexal
SAS Employee

@sumandas1982 ,

 

How exactly are you running a Python code? From a Jupyter notebook?

sumandas1982
Calcite | Level 5

Alexal,

 

Thanks for the reply.

Let me describe the complete story.

I have written a small python code to test connection from SAS Viya -

 

This is the python code -

 

import sys

print(sys.executable)

print(sys.version)

 

and saved  in  /opt/sas/   as test.py

 

Then I wrote a small SAS code to call this python code -

data _null_;

    infile "python /opt/sas/test.py"  pipe end=eof;

    input;

    put _infile_;

run;

 

When I run this sas code in SAS studio, I got the below details in log -

sumandas1982_0-1594864426257.png

 

In this log, it says that python interpreter version is 2.6.6 and the location of the python is /usr/bin/python.

 

When I call the test.py from terminal server -

sumandas1982_1-1594864666587.png

I see that the interpreter is 3.6.6 and the location is /opt/sasinside/anaconda3/bin/python

 

I would like to use 3.6.6 version for SAS Viya instead of 2.6 version which is old. There must be some configuration file in sas viya which indicates to use 2.6 version instead of 3.6 python. I am not sure where is that configuration file and what needs to be updated so viya will connect to 3.6 python.

 

Please let me know if you need any other details.

 

Thanks,

Suman

 

 

alexal
SAS Employee

It seems like you have used a conda command to create a Python virtual environment. If that is true, you have to initialize the same virtual environment when you are calling a Python program from the X session inside SAS.

sumandas1982
Calcite | Level 5

Thank you Alexal for your reply.

 

Do you have any example code how to initialize conda virtual environment in SAS?

 

 

sumandas1982
Calcite | Level 5

Thanks. I have used the link below to setup the SAS Viya VDMML open source code for Python -

 

https://communities.sas.com/t5/SAS-Communities-Library/How-to-execute-Python-or-R-models-using-the-O...

 

And it is working now. But I am still facing the issue from SAS Studio in viya to use Python. I will try the way you have suggested.

Thanks,

Suman

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Discussion stats
  • 6 replies
  • 2235 views
  • 0 likes
  • 2 in conversation