Products Resources Support About Us

Rocket Software

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.

What you want to do, but for Python 2.7.6, can be found in this example.

I don’t believe the build of Python 3.6.1 currently available for z/OS supports the “//” filename syntax. This will be supported in an upcoming release.

Could I ask the tentative schedule of the upcoming release? It’s because Python 3 is the current trend.

Unfortunately, this sort of enhancement has to be a “when we have time” for users that are not on a support contract. We do provide 24x7 support and priority service for enhancements for customers on support and support contracts are very reasonably priced. Sorry, but we must prioritize paying customers first.
Best regards,
-Peter

For anyone who has interest, could you roughly tell us the price for this kind of support?

Pricing for paid support is handled by Rocket sales (I am with engineering). Without knowing your region required to direct you to a specific sales person, you need to make an inquiry here: http://www.rocketsoftware.com/zos-open-source-tools-support
Best,
-Peter

Possible work-arounds:

  1. For a not too big MVS dataset you could consider copying it to Unix before processing with Python.

  2. Python2.7.13 also does support processing MVS files with filename starting with 2 slashes

  3. With Python 3.6.1 you could use ftplib to localhost and access the ‘local’ MVS datasets:

from ftplib import FTP
ftp = FTP(‘localhost’)
ftp.login(‘mm’,‘password’)
‘230 MM is logged on. Working directory is "/x/mm’

ftp.cwd(’//mm.sys.’)
‘250 “MM.SYS.” is the working directory name prefix.’

You even can get a nice listing of the MVS datasets

>>> ftp.dir()     

By the way, FTP also supports reading record structures (RDW option) …

:grinning:

First of all, thanks for the suggested work-arounds. However, as the MVS files I need to handle are very large which are not convenient to copy to USS.

Secondly, where can I find the Python 2.7.12 beta as I can only find 2.7.13?

Thirdly, is it possible to use Python 2 program to feed records to Python 3.6.1 program? If it is possible, what is the best way to do it?

ad2) actually I meant Python 2.7.13 and not 2.7.12 beta which was a pre-release.

I will correct this in the original post

ad3) I have not experimented with this. Perhaps this would work with (module) pipes.

I have installed both 2.7.13 and 3.6.1. According to the README, I can set both library in the .profile. But I don’t know how to set “both”. Could anyone advise me how to set it such that I can run both 2.7.13 python program and 3.6.1 program at the same time?

Currently, my .profile is shown as below:
export _BPXK_AUTOCVT=ON
INSTALL=/usr/lpp/python
export RELEASE_NAME=python-2017-04-12
export RELEASE_TYPE=py36
export RELEASE_DIR=$INSTALL/${RELEASE_NAME}-${RELEASE_TYPE}
export PYTHON_ENV=python36
export PYTHON_HOME=$RELEASE_DIR/$PYTHON_ENV
export PATH=$PYTHON_HOME/bin:$PATH
export LIBPATH=$PYTHON_HOME/lib:$LIBPATH
export FFI_LIB=$PYTHON_HOME/lib/ffi
export TERMINFO=$PYTHON_HOME/share/terminfo
export PKG_CONFIG_PATH=$PYTHON_HOME/lib/pkgconfig:$PYTHON_HOME/share/pkgconfig
export CURL_CA_BUNDLE=$PYTHON_HOME/etc/ssl/cacert.pem

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!

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)

1 Like

Hi Tatyana,

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

Fran,
You are welcome!

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