Software⏱️ 3 min read📅 2026-06-11

How to Fix: Python error In linux

Python error on Linux system, unable to find platform independent libraries and modules.

Quick Answer: Try reinstalling Python with the correct library directory specified, or use a Linux rescue tool to restore the original installation.

This error occurs when the default Python installation is removed from Linux using an RPM command without removing its dependencies. As a result, attempting to install Python 2.7 manually may lead to conflicts and errors like 'Could not find platform independent libraries ' or 'ImportError: No module named site'. This issue affects users who have removed the default Python installation and are experiencing difficulties in installing alternative versions.

This error can be frustrating for developers who rely on Python for their work. The inability to invoke Python manually and use popular tools like yum can significantly impact productivity. In this guide, we will walk you through the steps to resolve this issue and restore your system to its original state.

🔍 Why This Happens

  • The primary reason for this error is the removal of the default Python installation without removing its dependencies. This can lead to conflicts with other packages installed on the system.
  • An alternative reason could be the incorrect usage of the '--libdir' option when installing Python 2.7, which may have caused issues with the library paths.

🔧 Proven Troubleshooting Steps

Reinstalling the default Python installation

  1. Step 1: Open a terminal and run the command 'sudo yum install python' to reinstall the default Python installation.
  2. Step 2: This will automatically remove any conflicting packages and restore the system's original library paths.
  3. Step 3: Once the installation is complete, restart your system to ensure all changes take effect.

Restoring the original library paths

  1. Step 1: Edit the /etc/python.conf file using a text editor and change the 'python_lib_dir' line to point to the correct location of the Python libraries. For example, you can use '/usr/lib64/python3.6' instead of '/usr/local/lib/python3.2'.
  2. Step 2: Save the changes and restart your system to apply the new configuration.

✨ Wrapping Up

To resolve this issue, we recommend reinstalling the default Python installation using 'sudo yum install python' or restoring the original library paths by editing the /etc/python.conf file. These steps should help you restore your system to its original state and enable you to use Python without any issues.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions