Troubleshooting

This section describes some common issues that you might encounter while creating your IBM® Open Enterprise SDK for Python applications.

For more troubleshooting information about multiprocessing considerations, see Multiprocessing considerations.

For more troubleshooting information about tagging files, see Tagging files.

Files extracted from ZIP archives have lost their sticky bit (S_ISVTX)

Due to compatibility and security reasons, ZIP member files will have the sticky bit turned off when extracted from their parent archive. You can manually set the sticky bit afterward to turn them on. The sticky bit can be set with the following command under z/OS® Unix System Services:
chmod +t {name_of_file}
Notice that the sticky bit for directories will not be affected.

IBM z/OS C/C++ Failures

  • When using pip to install packages, they might require a C/C++ compiler. See Using IBM C/C++ compilers with IBM Open Enterprise SDK for Python for more information on setting up a C/C++ compiler.

    You can test your compiler by creating a new file with the following c program:
    
    #include <stdio.h>
    
    int main()
    {
        printf("Hello, world!\n");
        return 0;
    }
    and run <path_to_your_c_compiler> <filename.c> to compile the file, and use ./a.out to run it.

    If successful, the program will print out Hello, world! which means your compiler is ready to use with IBM Open Enterprise SDK for Python.

  • While using IBM XL C/C++ 2.4.1 for z/OS 2.5, you may encounter the following error:
     FSUM3224 xlclang++: Fatal error in /usr/lpp/cbclib/xlclang/exe/clcdrvr: signal 9 received

    This error occurs when the installation has not been completed. See Using IBM C/C++ compilers with IBM Open Enterprise SDK for Python for download address for each C/C++ compiler.

  • If your z/OS system is missing datasets which are created during the IBM z/OS XL C/C++ install process, you will encounter the following error:
    EDC5129I No such file or directory. (errno2=0x05940252) FSUM3221 xlc: Cannot spawn program /usr/lpp/cbclib/xlc/exe/ccndrvr - error: command '/bin/xlc' failed with exit code 255
    You should confirm if it has been installed successfully.
  • If a package may have been tagged incorrectly while using IBM z/OS XL C/C++, while importing that package you will encounter an error similar to:
    Import Error: CEE3512S An HFS load of module <path to filename.so> failed. The system return code is 0000000130 and the reason code is 0BDF0C27.
    Verify if the shared library is untagged, by running:
    ls -alT <path to filename.so>
    If the file is tagged, with the following output message:
    t ISO8859-1 T=on
    you can remove the tag with the following command:
    chtag -r <filename.so>

Fatal Python Error: Failed to get random numbers

  • Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python
    This error shows up when you try to run Python without enabling Integrated Cryptographic Services Facility (ICSF). ICSF is typically responsible for supplying random data for /dev/urandom. You can run the following command to verify whether ICSF is enabled or not on your system.
    head -c10 /dev/urandom
  • If ICSF is enabled, you will see random data and if it is not enabled on your system, you will encounter Internal Error. If you are on z13®, you must enable Integrated Cryptographic Services Facility (ICSF) on your systems where IBM Open Enterprise SDK for Python runs.

For more information including installation guide, please refer to ICSF System Programmer's Guide and ICSF Administrator's Guide.

Python execution failure due to semaphore exhaustion

When semaphore exhaustion occurs on a machine, it can cause Python programs to fail in various ways. One common example will be an error message as follows:

_multiprocessing.SemLock(PermissionError: [Errno 139] EDC5139I Operation not permitted.

To diagnose whether semaphore exhaustion is an issue, you can run the following command to examine the number of semaphores that your user is currently using.

ipcs | grep <your ID>

If you run ipcs -y, you can get the limits for semaphores or the shared memory. If the number reported is close to that number, then it's likely that you are hitting the limit when running Python.

The following example shows how to approach cleaning up semaphore usage under your user id:

ipcs | grep <your ID> | awk '{print $2}' > semaphores_example.txt
for i in $(cat semaphores_example.txt) ; do { ipcrm -s $i >> /dev/null 2>&1; }; done;
for i in $(cat semaphores_example.txt) ; do { ipcrm -m $i >> /dev/null 2>&1; }; done;
rm semaphores_example.txt

Not found error for encodings module

You might run a Python script and get encodings module not found errors. The presence of the PYTHONHOME environment variable can lead to the mixing of Python versions:

$ python3
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x26b7980000000001 (most recent call first):
CEE5207E The signal SIGABRT was received.
ABORT instruction
This error is generally caused by setting the PYTHONHOME environment variable to a conflicting location. Try to set the PYTHONHOME environment variable and execute Python again using the following commands:
$ unset PYTHONHOME
$ python3

Errors when using setuptools

  • If you see the following errors,
    FSUM3010 Specify a file with the correct suffix (.C, .hh, .i, .c, .i, .s, .o, .x, .p, .I, or .a), or a corresponding data set name....
    export the following environment variables:
    export _CC_CCMODE=1
    export _CXX_CCMODE=1
    export _C89_CCMODE=1
    export _CC_EXTRA_ARGS=1
    export _CXX_EXTRA_ARGS=1
    export _C89_EXTRA_ARGS=1
    
  • If you see the following warnings,
    WARNING CCN3236 /usr/include/unistd.h:1169  Macro name _POSIX_THREADS has been redefined.
    you can safely ignore as Python forces POSIX thread behavior in modules for compatibility reasons.
    If you see the similar error with xlc:
    "/usr/include/unistd.h", line 1169.16: CCN5848 (S) The macro name "_POSIX_THREADS" is already defined with a different definition.
    then setting the appropriate qlanglvl with redefmac can be used to work around this.

    For both xlclang and xlc, if non-POSIX thread behavior is required, you might undefine this macro in your source files. This action should be done with care and is not recommended.

  • If you see the following error while trying to install a package:
    error: command '/usr/lpp/IBM/oelcpp/v2r0/bin/clang' failed: EDC5129I No such file or directory.
    This means the package that you are attempting to install requires a C compiler. If you have one installed in a non-standard location, you can specify it with the following command:
    export CC=<path to C compiler>
    export CXX=<path to C++ compiler>
    If you do not have a C/C++ compiler installed on your system, see Using IBM C/C++ compilers with IBM Open Enterprise SDK for Python for obtaining a C/C++ compiler.

Errors for incorrectly tagged files

  • If you see an error as the following error message:
    SyntaxError: Non-UTF-8 code starting with '\x84' in file test.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
    ensure that the file is either encoded as ASCII or IBM-1047 and correctly tagged. The interpreter doesn't attempt to auto-detect the file encoding if the file is already tagged. If the file is correctly tagged and encoded, check the non-printable characters in the file.

Issues building and installing PyPI packages

Not all packages can be built by using the default options provided in Python, and a given PyPI package may not contain compatible options for your C or C++ compiler definitions. You can often avoid compile failures, for example, changing C standard level, by using the environment variable CFLAGS.

For packages requiring C11 and later, see Using IBM C/C++ compilers with IBM Open Enterprise SDK for Python for obtaining the recommended compiler.

If a failure to import a library after a successful install happens, the following error message will be displayed:
Import Error: CEE3512S An HFS load of module <path to filename.so> failed. The system return code is 0000000130 and the reason code is 0BDF0C27.
A package shared library may get tagged incorrectly when using the xlc utility. Verify that the shared library is untagged by running the following line:
ls -alT <path to filename.so>
If the file is tagged, with the output being similar to the following line:
t ISO8859-1 T=on
you can remove the tag with the following command:
chtag -r <filename.so>

Packages unable to install cffi within a virtual environment

c/_cffi_backend.c:15:10: fatal error: 'ffi.h' file not found
This error shows up when you try to install a package and require ffi.h file into a virtual environment without using site-packages. IBM Open Enterprise SDK for Python is distributed with several packages installed, including cffi. To get access when using a virtual environment, create the environment with the flag --system-site-packages as the following example:
<path to python3 install>/bin/python3 -m venv --system-site-packages venv

Redirecting to a file in a shell script results in garbled output

If you are redirecting to a file in a shell script, and notice that the Python output is garbled, set the following environment variables:
export _TAG_REDIR_ERR=txt
export _TAG_REDIR_IN=txt
export _TAG_REDIR_OUT=txt

UnicodeDecodeError error message

  • UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa3 in position 0: invalid start byte
    This error is returned when there is a conversion error. This error message usually refers to a file that is tagged incorrectly, or has a wrong encoding specified. To verify whether the encodings are correct, see Codesets and translation for more details.

Failure to launch the new IBM Open Enterprise SDK for Python 3.14 REPL

If the new Python 3.14 REPL launch fails, the following warning message is displayed:
Python 3.14.0 (heads/pyz_dev-3.14:bd1cf5a763, Oct 31 2024, 14:42:31) [Clang 18.1.0 (build 221a599)] on zos
Type "help", "copyright", "credits" or "license" for more information.
warning: can't use pyrepl: 
>>>
To use the new REPL in IBM Open Enterprise SDK for Python 3.14, unset the TERMINFO variable or export it to point to the TERMINFO database directory. To increase reliability of the new REPL, verify that the terminal definition exported by the TERM exists in the terminfo database. It is recommended to use an ANSI-based-xterm, xterm-color, etc. terminal.
export TERMINFO=<path_to_python_install>/usr/lpp/IBM/python/v3r14/pyz/share/terminfo
Note:

If you have exported it, make sure to revert it or unset it after using IBM Open Enterprise SDK for Python.

Running pip without AUTOCVT results in corrupted file generation

Running pip without AUTOCVT causes extra files to be created. These file names use conflicting encodings that results difficulty in deleting the files.

To resolve corrupt file generation, you need to set up the correct environment variables following the instructions in the IBM Open Enterprise SDK for Python documents. For more information on how to set up environment variables, refer to Set environment variables.

Specifically, you must set the following correct environment variables for auto conversion:
export_BPXK_AUTOCVT=ON
export_CEE_RUNOPTS= “FILETAG(AUTOCVT,AUTOTAG) POSIX(ON))”
Perform the following instructions to delete the extra files by referencing their inodes:
  1. To list the inodes corresponding to each file, use the following command:
    ls -i
    This example shows how to use the command to list the inodes associated with each file:
    $> ls -i
    215261                         	    150674 activate.fish               	213402 python3                   183585
    183584                             	150666 pip                         	213400 python3.12                215262
    325137 Activate.ps1                	150667 pip3                        	183586                    	 
    150672 activate                    	150668 pip3.12                     	277227            	 
    150673 activate.csh                	213401 python                      	183583 
  2. To delete the generated files, use the following command:
    find . -inum <insert inum> | xargs rm –f 
    This example shows the usage of command:
    $> find . -inum 215261 | xargs rm -f

Error installing PyPI package using requirements.txt file encoded in EBCDIC

When using pip to install packages through a requirements.txt file encoded in EBCDIC, you may encounter the following error:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa4 in position 0: invalid start byte
To resolve the error, convert the existing EBCDIC-encoded requirements.txt file to ASCII using the following command:
iconv -T -f IBM-1047 -t ISO8859-1 requirements.txt > requirements_ascii.txt
Alternatively, you can re-create the requirements.txt file using ASCII with the following command:
pip freeze > requirements.txt

ssl.SSLError: [X509: NO_CERTIFICATE_OR_CRL_FOUND] no certificate or crl found

When you see the following error message:
ssl.SSLError: [X509: NO_CERTIFICATE_OR_CRL_FOUND] no certificate or crl found
Ensure that the certificate is either encoded as ASCII or IBM-1047 and correctly tagged.
To verify the certificate is correctly tagged, run the following command:
ls -alT <path to the certificate>
If the certificate is untagged, you will see the following output:
- untagged T=off
Tag the certificate with the correct encoding, by running the following command:
chtag -tc <encoding> <path to the certificate>