When you encounter the "Failed to initialize NSS library" error during yum operations on RHEL 7.7.3, it typically stems from corrupted NSS libraries or mismatched Python modules. The specific error message about being unable to "import name ts" indicates a deeper Python dependency issue.
First, verify your current Python environment with:
python --version rpm -qa | grep python-nss
On RHEL 7.7.3, you should see Python 2.7.5 and python-nss-0.16.0 or later. If these versions don't match, we've found our problem source.
1. Reinstall NSS Packages
sudo yum remove nss nss-util nss-sysinit nss-tools sudo yum clean all sudo yum install nss nss-util nss-sysinit nss-tools
2. Fix Python-NSS Binding
The critical step is reinstalling the python-NSS bindings:
sudo rpm -e --nodeps python-nss sudo yum install python-nss
3. Verify Library Paths
Check if NSS libraries are properly linked:
ls -l /usr/lib64/libnss3.so ldconfig -p | grep nss3
If links are broken, recreate them:
sudo ln -sf /usr/lib64/libnss3.so /usr/lib64/libnss3.so.1d
If the issue persists, manually verify the Python module integrity:
python -c "import NSS; print(NSS.__file__)"
This should output:
/usr/lib64/python2.7/site-packages/NSS/__init__.py
If not, force reinstall all dependencies:
sudo yum reinstall python python-libs python-nss
To avoid future occurrences:
- Regularly update all packages:
sudo yum update
- Maintain consistent Python environments
- Avoid manual library modifications
When working with RHEL 7.7.3 systems, you might encounter this frustrating error during package updates:
error: Failed to initialize NSS library There was a problem importing one of the Python modules required to run yum. The error leading to this problem was: cannot import name ts
This error typically occurs due to a mismatch between:
- Python NSS bindings (python-nss)
- The system's NSS library version
- Yum's dependencies
First, verify your current Python and NSS versions:
python -V rpm -q nss nss-util nss-sysinit nss-tools
Here's the most reliable fix sequence:
# Reinstall critical components sudo yum clean all sudo rpm -e --nodeps nss nss-util nss-sysinit nss-tools sudo yum install nss nss-util nss-sysinit nss-tools python-nss
If you encounter dependency issues, try forcing the reinstallation:
sudo rpm -Uvh --force /var/cache/yum/x86_64/7Server/nss-*.rpm
For systems where the standard fix doesn't work:
# Backup first sudo cp /usr/lib64/python2.7/site-packages/nss/__init__.py{,.bak} # Modify the Python NSS binding sudo sed -i 's/from _nss import \*/from _nss import \*, ts/' /usr/lib64/python2.7/site-packages/nss/__init__.py
After applying fixes, test with:
python -c "import nss; print(dir(nss))" | grep ts yum check-update
To avoid similar issues:
- Regularly update all packages:
sudo yum update -y
- Maintain consistent versions of security libraries
- Monitor Red Hat's errata for NSS updates
Consider these nuclear options:
# Rebuild yum cache sudo rm -rf /var/cache/yum/* sudo yum clean all sudo yum makecache # Worst case - reinstall yum sudo rpm -e yum yum-metadata-parser python-urlgrabber sudo yum install yum yum-utils