Oserror: looks like you do not have git installed, please install.\

I have created a container to run Jupyterlab (to run tensorflow). I try to replicate Text Classification example and I ran the notebook at my container.

However, I encounter this error while running one of the code:

Error Message: OSError: Looks like you do not have git installed, please install.

I did install git-lfs in my ubuntu (WSL).

I tried many possible solutions but the issue still persists.

Hi!
Ok, from your message I gather that you’re trying to run a Jupyter notebook within a container. When the notebook attempts to interact with git, an OSError suggests that git is not installed. Despite installing git-lfs on your Ubuntu (WSL), the issue persists.

So, I would approach it like this:

  • Containers run in isolation from the host OS, so if git is installed on the host, the container may not have access to it.
  • Installing git-lfs doesn’t necessarily mean git itself is installed. Git Large File Storage (git-lfs) is an extension but not a replacement for git.
  • The error might originate from the Python environment within the container rather than the OS layer.

And if you think you found the issue try this,:

  1. Install git in the container: If git is not present in the container, you’ll need to install it there.

    • Open a shell into the container: docker exec -it <container_name_or_id> /bin/bash
    • Install git: apt-get update && apt-get install -y git
  2. Ensure PATH is correctly set: It’s possible git is installed but not found in the PATH.

    • In the container, check the path: echo $PATH
    • Ensure the directory containing the git executable is in the PATH.
  3. Check from Python: Sometimes, the Python environment might not detect installed packages correctly.

    • In the Jupyter notebook, try running:
      import shutil
      shutil.which("git")
      
      This should return the path to the git executable, if available.

In short:

  • Step into your container and ensure git is properly installed.
  • Double-check your container’s PATH variable.
  • Test git accessibility from your Python environment inside Jupyter.

Hope this helps!

Hi I followed your steps but the error still persists. However, the error resolved after running this code: apt-get install git-lfs in docker environment.

Thank you so much.

1 Like