ImportError: libstdc++.so.6

I’ve started my first project from python gemini backend template and even without changing anything, I get this error:

$ python main.py 
Traceback (most recent call last):
  File "/home/user/py-backed-gemini/main.py", line 4, in <module>
    import google.generativeai as genai
  File "/home/user/py-backed-gemini/.venv/lib/python3.11/site-packages/google/generativeai/__init__.py", line 45, in <module>
    from google.generativeai import caching
  File "/home/user/py-backed-gemini/.venv/lib/python3.11/site-packages/google/generativeai/caching.py", line 21, in <module>
    from google.generativeai import protos
  File "/home/user/py-backed-gemini/.venv/lib/python3.11/site-packages/google/generativeai/protos.py", line 74, in <module>
    from google.ai.generativelanguage_v1beta.types import *
  File "/home/user/py-backed-gemini/.venv/lib/python3.11/site-packages/google/ai/generativelanguage_v1beta/__init__.py", line 21, in <module>
    from .services.cache_service import CacheServiceAsyncClient, CacheServiceClient
  File "/home/user/py-backed-gemini/.venv/lib/python3.11/site-packages/google/ai/generativelanguage_v1beta/services/cache_service/__init__.py", line 16, in <module>
    from .async_client import CacheServiceAsyncClient
  File "/home/user/py-backed-gemini/.venv/lib/python3.11/site-packages/google/ai/generativelanguage_v1beta/services/cache_service/async_client.py", line 32, in <module>
    from google.api_core import gapic_v1
  File "/home/user/py-backed-gemini/.venv/lib/python3.11/site-packages/google/api_core/gapic_v1/__init__.py", line 16, in <module>
    from google.api_core.gapic_v1 import config
  File "/home/user/py-backed-gemini/.venv/lib/python3.11/site-packages/google/api_core/gapic_v1/config.py", line 23, in <module>
    import grpc
  File "/home/user/py-backed-gemini/.venv/lib/python3.11/site-packages/grpc/__init__.py", line 22, in <module>
    from grpc import _compression
  File "/home/user/py-backed-gemini/.venv/lib/python3.11/site-packages/grpc/_compression.py", line 20, in <module>
    from grpc._cython import cygrpc
ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory
(.venv) py-backed-gemini-5878098:~/py-backed-gemini$
2 Likes

I ran into this same issue. Using a suggestion from this nixOS thread, I set the LD_LIBRARY_PATH in the nix config and rebuilt the environment. I’m not a nix expert, so I’m not sure if this is the proper way to accomplish this, but it made my app work!

Here is the relevant block in my dev.nix file:

# Sets environment variables in the workspace
env = {
      LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
};
3 Likes

This mf worked! Thank you

Wanted to update from the IDX team that we have identified the root cause and fixed this issue!