ImportError: cannot open shared object file: No such file or directory

I’m trying to import a package called spacy for NLP, but I keep getting this error:

Traceback (most recent call last):
  File "/home/runner/Voice-Synthathizer-1/", line 9, in <module>
    import spacy
  File "/home/runner/Voice-Synthathizer-1/venv/lib/python3.9/site-packages/spacy/", line 6, in <module>
    from .errors import setup_default_warnings
  File "/home/runner/Voice-Synthathizer-1/venv/lib/python3.9/site-packages/spacy/", line 2, in <module>
    from .compat import Literal
  File "/home/runner/Voice-Synthathizer-1/venv/lib/python3.9/site-packages/spacy/", line 3, in <module>
    from thinc.util import copy_array
  File "/home/runner/Voice-Synthathizer-1/venv/lib/python3.9/site-packages/thinc/", line 5, in <module>
    from .config import registry
  File "/home/runner/Voice-Synthathizer-1/venv/lib/python3.9/site-packages/thinc/", line 2, in <module>
    import confection
  File "/home/runner/Voice-Synthathizer-1/venv/lib/python3.9/site-packages/confection/", line 13, in <module>
    import srsly
  File "/home/runner/Voice-Synthathizer-1/venv/lib/python3.9/site-packages/srsly/", line 1, in <module>
    from ._json_api import read_json, read_gzip_json, write_json, write_gzip_json
  File "/home/runner/Voice-Synthathizer-1/venv/lib/python3.9/site-packages/srsly/", line 6, in <module>
    from . import ujson
  File "/home/runner/Voice-Synthathizer-1/venv/lib/python3.9/site-packages/srsly/ujson/", line 1, in <module>
    from .ujson import decode, encode, dump, dumps, load, loads  # noqa: F401
ImportError: cannot open shared object file: No such file or directory

I did some research on this and this is what I’ve tried:

  • Adding this to the .nix file:
  shellHook = ''
    # fixes libstdc++ issues and issues
  • Putting the LD_LIBRARY_PATH part outside of the string

  • Replacing :/run/opengl-driver/lib/ with

Please help me as I really do not know what to do from here…

I was able to get spacy to work by installing it from the package manager first.
Screenshot 2022-12-26 8.42.29 AM

Then you might need something like en_core_web_sm and you install this by running python -m spacy download en_core_web_sm in the shell.


The Problem

I found out the issue, it was because I commented out the [interpreter] part of the .replit file.

This part add a very important part that was setting the LD_LIBRARY_PATH environment variable to python’s pre-defined library path.

That was causing the error in the first place (as packages did not know where they were located… correct me if I’m wrong)

The Solution

Obviously, you can just un-comment the interpreter part , BUT you can also just extract eny definition in the “env” part of the [interpreter.command] section into the [env] section instead. Like this:

#									|
[env]#							    V
What your `.replit` file should look like
# The command that runs the program. If the interpreter field is set, it will have priority and this run command will do nothing
run = "python3"

# The primary language of the repl. There can be others, though!
language = "python3"
entrypoint = ""
# A list of globs that specify which files and directories should
# be hidden in the workspace.
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]

# Specifies which nix channel to use when building the environment.
channel = "stable-21_11"

# The command to start the interpreter.
# [interpreter]
#   [interpreter.command]
#   args = [
#     "stderred",
#     "--",
#     "prybar-python3",
#     "-q",
#     "--ps1",
#     "\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
#     "-i",
#   ]

# Fix Import issues /w some python packages

VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
PYTHONPATH = "${VIRTUAL_ENV}/lib/python3.8/site-packages"
POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry"

# Enable unit tests. This is only supported for a few languages.
language = "python3"

# Add a debugger!
support = true

  # How to start the debugger.
  transport = "localhost:0"
  startCommand = ["dap-python", ""]

    # How to communicate with the debugger.
    dapTcpAddress = "localhost:0"

    # How to tell the debugger to start a debugging session.
    command = "initialize"
    type = "request"

      adapterID = "debugpy"
      clientID = "replit"
      clientName = ""
      columnsStartAt1 = true
      linesStartAt1 = true
      locale = "en-us"
      pathFormat = "path"
      supportsInvalidatedEvent = true
      supportsProgressReporting = true
      supportsRunInTerminalRequest = true
      supportsVariablePaging = true
      supportsVariableType = true

    # How to tell the debugger to start the debuggee application.
    command = "attach"
    type = "request"

      logging = {}

# Configures the packager.
language = "python3"
ignoredPackages = ["unit_tests"]

  enabledForHosting = false
  # Enable searching packages from the sidebar.
  packageSearch = true
  # Enable guessing what packages are needed from the code.
  guessImports = true

# These are the files that need to be preserved when this 
# language template is used as the base language template
# for Python repos imported from GitHub
requiredFiles = [".replit", "replit.nix", ".config", "venv"]


pattern = "**/*.py"

start = "pylsp"


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