Error while importing Tensorflow in Python 2.7 in Ubuntu 12.04. 'GLIBC_2.17 not found'
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Importing TensorFlow in Python 2.7 on an antiquated system like Ubuntu 12.04 can be fraught with challenges, especially when dealing with system dependencies that are long outdated. One of the common issues faced is an error related to the GNU C Library, specifically: GLIBC_2.17 not found. This problem stems from an incompatibility between the TensorFlow binary and the available GLIBC version on the system.
Understanding the Issue
What is GLIBC?
GLIBC (GNU C Library) is a core part of the GNU system and the GNU/Linux system. It provides the system programming API for C programs and is used by many components, including the kernel and other standard libraries. It is essential for program execution as it provides standard C libraries for user space applications on Linux.
Root Cause of the Error
The error message GLIBC_2.17 not found indicates that the version of GLIBC installed on your system is older than 2.17, which is the minimum version required by the TensorFlow binary you are trying to import. Ubuntu 12.04 comes with a much older version of GLIBC, typically 2.15, which lacks some of the functions required by newer applications.
Solutions and Workarounds
To resolve this issue, you have several options, although they vary in complexity and impact. Below is a summary of potential solutions:
| Solution | Description |
| Upgrade GLIBC | Compile and install a newer version of GLIBC. This is complex and risky for system stability. |
| Use Docker | Run a container with a newer base image that has the appropriate GLIBC version. |
| Upgrade the Operating System | Upgrade from Ubuntu 12.04 to a later version that supports GLIBC 2.17 or higher natively. |
| Use an Older TensorFlow Version | Find a TensorFlow version compatible with GLIBC 2.15, though features may be limited. |
1. Upgrading GLIBC
Upgrading GLIBC directly on an older system like Ubuntu 12.04 is a risky endeavor as it can lead to system instability. If you choose this path, consider the following steps:
After installation, you need to run your Python script with an updated LD_LIBRARY_PATH:
2. Using Docker
Docker can provide an isolated environment using a newer version of Ubuntu or another Linux distribution where the required GLIBC is present. Here is a brief guide:
- Install Docker if it is not already installed on your system.
- Pull a Docker image for a newer Ubuntu version:
docker pull ubuntu:18.04 - Start a container:
docker run -it ubuntu:18.04 /bin/bash - Within the container, install Python, TensorFlow, and other dependencies.
3. Operating System Upgrade
Upgrading to a newer version of Ubuntu is perhaps the most straightforward and least error-prone approach. Later versions, like Ubuntu 14.04 or 16.04, come with the necessary GLIBC versions.
4. Using an Older TensorFlow Version
Another approach is to find a TensorFlow version that is compatible with your current system. This is likely to be an earlier version with fewer features. You can search PyPI or the TensorFlow GitHub releases for specific versions.
Additional Considerations
- End-of-Life Software: Running outdated software like Ubuntu 12.04 can have security implications. Always consider upgrading to a supported version for security patches and support.
- Python 2.7: Python 2.7 is officially dead as of January 1, 2020. Consider upgrading to Python 3 for enhanced features and security.
- Temporary Workarounds: If none of the solutions seem feasible due to constraints, virtual machines or remote services like Google Colab can be temporary alternatives.
Conclusion
The GLIBC_2.17 not found error is a challenging obstacle for legacy systems, but it can be addressed with several workarounds. While upgrading GLIBC directly may be perilous, using Docker or upgrading the operating system are viable options. With the phasing out of Python 2.7, it is also critical to consider transitioning to a more modern development environment.

