How can I install libmagic?

I’ve a Python Repl where I installed unstructured[local-inference]

One of its dependencies is libmagic-devfor filetype detection

When I run my code I got:

libmagic is unavailable but assists in filetype detection on file-like objects.Please consider installing libmagic for better results.

I have tried to install libmagic, adding the following deps to my replit.nix file without success:

pkgs.python310Packages.magic
pkgs.python310Packages.python-magic

Hi @Klaudioz , try entering pip install libmagic into the Shell.

Thanks for your answer. I got the same message after running:

pip install libmagic
poetry add libmagic

So… does it work now?

No, I got the same message unfortunately:

libmagic is unavailable but assists in filetype detection on file-like objects.Please consider installing libmagic for better results.

1 Like

But… you literally tried to install it and it said it was not available, and then they want you to install it again!? That makes no sense.

It looks like everything was installed successfully. Next, I run my program again and I got the same message,

I can see the following directory:

/venv/lib/python3.10/site-packages/libmagic-1.0-py3.10.egg-info

Also, my pyproject.toml was updated:

[tool.poetry]
name = "python-template"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
python = ">=3.10.0,<3.11"
numpy = "^1.22.2"
replit = "^3.2.4"
Flask = "^2.2.0"
urllib3 = "^1.26.12"
openai = "0.27.6"
pymongo = "^4.3.3"
langchain = "0.0.172"
pinecone-client = "2.2.1"
tabulate = "0.9.0"
unstructured = {extras = ["local-inference"], version = "^0.7.7"}
python-magic = "^0.4.27"
cffi = "^1.15.1"
libmagic = "^1.0"

[tool.poetry.dev-dependencies]
debugpy = "^1.6.2"
replit-python-lsp-server = {extras = ["yapf", "rope", "pyflakes"], version = "^1.5.9"}

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

You used poetry install libmagic?

poetry add libmagic

I’ve tried a lot of things, I know the package is very old

Some references: failed to find libmagic - Using Django - Django Forum

I’ve created a bounty for this issue:

https://replit.com/bounties/@Klaudioz/using-libmagic-in-re

1 Like

Did you ever resolve this? I am having the same issue.

Yes, using:

{ pkgs }: {
  deps = [
    pkgs.cln
    pkgs.python38Full
    pkgs.nixos-rebuild
    pkgs.winePackages.minimal
    pkgs.sudo
    pkgs.python310Full
    pkgs.replitPackages.prybar-python310
    pkgs.replitPackages.stderred
    pkgs.libffi
    pkgs.python310Packages.magic
    pkgs.python310Packages.python-magic
    pkgs.python310Packages.typecode-libmagic
    pkgs.python310Packages.typecode
  ];
  env = {
    PYTHON_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
      pkgs.file
      # Needed for pandas / numpy
      pkgs.stdenv.cc.cc.lib
      pkgs.zlib
      # Needed for pygame
      pkgs.glib
      # Needed for matplotlib
      pkgs.xorg.libX11
    ];
    PYTHONHOME = "${pkgs.python310Full}";
    PYTHONBIN = "${pkgs.python310Full}/bin/python3.10";
    LANG = "en_US.UTF-8";
    STDERREDBIN = "${pkgs.replitPackages.stderred}/bin/stderred";
    PRYBAR_PYTHON_BIN = "${pkgs.replitPackages.prybar-python310}/bin/prybar-python310";
  };
}
1 Like

That… Shouldn’t do anything. Repls don’t have sudo access, period.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.