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
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 -
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 -
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
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.
Thank you Alexal for your reply.
Do you have any example code how to initialize conda virtual environment in SAS?
I suppose you need to do this:
Thanks. I have used the link below to setup the SAS Viya VDMML open source code for Python -
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