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 5, 2017 12:14 PM 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.

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.

Dec 5, 2017 6:18 PM UTC

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.

Dec 8, 2017 6:14 PM UTC

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

Dec 9, 2017 4:36 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.

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

Dec 11, 2017 10:53 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.

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

Dec 13, 2017 11:07 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.

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) …

Dec 14, 2017 8:22 AM UTC

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) …

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?

Dec 14, 2017 9:47 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.

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.

Dec 19, 2017 3:49 PM 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.

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

Tatiana Balaburkina
Rocketeer
Dec 21, 2017 5:21 AM UTC

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?