Troubleshooting
This chapter describes some common issues that you might encounter while creating your IBM® Open Enterprise SDK for Python applications.
- Files extracted from ZIP archives have lost their sticky bit (S_ISVTX)
- IBM z/OS XL C/C++ failures
- Fatal Python Error: Failed to get random numbers
- Python execution failure due to semaphore exhaustion
- Not found error for encodings module
- Errors when using distutils
- Extended precision floating point support issue in NumPy library
- Errors for incorrectly tagged files
- Issues building and installing PyPI packages
- NumPy exec_command return value issue
- Packages unable to install cffi within a virtual environment
- Redirecting to a file in a shell script results in garbled output
- UnicodeDecodeError error message
- Running pip without AUTOCVT results in corrupted file generation
- Error installing PyPI package using requirements.txt file encoded in EBCDIC
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. Notice that the sticky bit for directories will not be affected.
IBM z/OS XL 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 3.11 for more information on setting up a C/C++ compiler.
#include <stdio.h>
int main()
{
printf("Hello, world!\n");
return 0;
}and run /bin/xlc <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.
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 255it
means that your z/OS® system is missing datasets which are
created during the IBM
z/OS XL C/C++ install process, and
you should confirm if it has been installed successfully. For information about installation, check
Using IBM C/C++ compilers with IBM Open Enterprise SDK for Python 3.11.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.ls -alT <path to filename.so>t ISO8859-1 T=onchtag -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
The above 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.
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 instructionThis
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
$ python3Errors when using distutils
-
If you see the following errors,
export the following environment variables: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 _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,
you can safely ignore as Python forcesWARNING CCN3236 /usr/include/unistd.h:1169 Macro name _POSIX_THREADS has been redefined.POSIXthread behavior in modules for compatibility reasons.If you see the similar error with xlc:
then setting the appropriate"/usr/include/unistd.h", line 1169.16: CCN5848 (S) The macro name "_POSIX_THREADS" is already defined with a different definition.qlanglvlwithredefmaccan 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:
This means the package that you are attempting to install requires a C compiler. If you have one in a non-standard location, you can specify it with the following command:error: [Errno 129] EDC5129I No such file or directory.: '/bin/xlc'
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 3.11 for obtaining a C/C++ compiler.CC=<path to C compiler> CXX=<path to C++ compiler>
Extended precision floating point support issue in NumPy library
The NumPy library in IBM Open Enterprise SDK for Python
does not support direct string conversion to the long double data type. Instead,
literals and strings are parsed to a double precision floating point number followed by a conversion
to the long double number. This indirect conversion introduces precision and range problems for
numbers outside of the double precision range.
Errors for incorrectly tagged files
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 detailsensure
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 xlc 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 above, see Using IBM C/C++ compilers with IBM Open Enterprise SDK for Python 3.11 for obtaining the recommended compiler.
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.ls -alT <path to filename.so>If the file is tagged, with the
output being similar to the following line:t ISO8859-1 T=onyou can remove the
tag with the following command:chtag -r <filename.so>NumPy exec_command return value issue
/bin/sh. While
executing these commands, only the user-provided environment variables are passed to the subprocess.
On z/OS, if the _BPXK_AUTOCVT environment
variable is not set to ON, the default output from terminal commands might be in
EBCDIC, which causes a mismatch error since the return value is expected to be in
ASCII. To avoid this issue, you should follow the command line below to set an
environment variable in the subprocess to get the return value in ASCII.
_BPXK_AUTOCVT='ON'Packages unable to install cffi within a virtual environment
c/_cffi_backend.c:15:10: fatal error: 'ffi.h' file not foundThe above
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 venvRedirecting to a file in a shell script results in garbled output
export _TAG_REDIR_ERR=txt
export _TAG_REDIR_IN=txt
export _TAG_REDIR_OUT=txtUnicodeDecodeError error message
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa3 in position 0: invalid start byteThis
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.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 toSet environment variables.
- _BPXK_AUTOCVT=ON
- _CEE_RUNOPTS= “FILETAG(AUTOCVT,AUTOTAG) POSIX(ON))”
- To list the inodes corresponding to each file, use the following command:
ls -iThis 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 - To delete the generated files, use the following
command:
find . -inum <insert inum> | xargs rm –fThis example shows the usage of command:$> find . -inum 215261 | xargs rm -f
Error installing PyPI package using requirements.txt file encoded in EBCDIC
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa4 in position 0: invalid start byteiconv -T -f IBM-1047 -t ISO8859-1 requirements.txt > requirements_ascii.txtpip freeze > requirements.txt