Skip to main content
Dec 2, 2017 12:55 PM UTC

z/OS Python 3.6.1 File Access

Does anyone know how to open a MVS dataset in python 3.6.1? And how to refer to a DD name in JCL? I have tried using open("//‘xxx.xxx.xxx’) and it returned ‘FileNotFoundError’ but the file is definitely exist! I can access the file in USS without any problem.

15 replies

Dec 21, 2017 7:45 AM UTC

Hi Fran,

Could you clarify (give an example) what you mean to run both version at the same time?

Hi Tatyana,

I would like to run a 3.6.1 program, in which I intend to use “subprocess” to call a 2.7.13 python program to open a MVS dataset and then feed records to the 3.6.1 program.

Currently, I have installed both versions in different install directories. However, I am struggling to set the environment variables for both versions. According to the README, I interpret that it means both should be in the same directory. However, the tar file has set the destination directory and sub-directory. How can I make them both in the same directory? Even though I can copy them together, if they are of the same file names (e.g. python in bin directory), they would be overwritten by the other one. I don’t quite understand how to make it work! Please help!

Tatiana Balaburkina
Rocketeer
Dec 27, 2017 8:54 AM UTC

Does anyone know how to open a MVS dataset in python 3.6.1? And how to refer to a DD name in JCL? I have tried using open("//‘xxx.xxx.xxx’) and it returned ‘FileNotFoundError’ but the file is definitely exist! I can access the file in USS without any problem.

Hi Fran,
Sorry for long reply. I would recommend you to use tne next settings:

Then you can you use python2 to run python 2.7 and python3 to run python 3.6. As I understand you need this call:

subprocess.call(“python2 script.py”, shell=True)

Dec 29, 2017 5:58 PM UTC

Hi Fran,
Sorry for long reply. I would recommend you to use tne next settings:

Then you can you use python2 to run python 2.7 and python3 to run python 3.6. As I understand you need this call:

subprocess.call(“python2 script.py”, shell=True)

Hi Tatyana,

Thank you very much. I have tested it and it works perfectly for me.

Tatiana Balaburkina
Rocketeer
Jan 9, 2018 5:18 AM UTC

Hi Tatyana,

Thank you very much. I have tested it and it works perfectly for me.

Fran,
You are welcome!

Mar 1, 2019 2:29 AM UTC

Does anyone know how to open a MVS dataset in python 3.6.1? And how to refer to a DD name in JCL? I have tried using open("//‘xxx.xxx.xxx’) and it returned ‘FileNotFoundError’ but the file is definitely exist! I can access the file in USS without any problem.

open MVS dataset in python 3.6
f = open("//‘my.dataset’", ‘rb’)