Skip to content

ModuleNotFoundError when running Python #3934

@dynamite-bud

Description

@dynamite-bud

Describe the bug

The problem is that the default current directory is /. Python gets its standard library from the files embedded in the python/python package, which are initially mounted in their default spot. When mounting the host's current directory to the guest's current directory, we end up clobbering the existing filesystem and core modules like encodings will no longer be available.

Steps to reproduce

$ wasmer run python/python --mapdir=.:. test.py
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00000000 (most recent call first):
error: RuntimeError: unreachable
    at <unnamed> (<module>[4661]:0x224edf)
    at <unnamed> (<module>[2033]:0xce8da)
    at <unnamed> (<module>[2030]:0xcde7a)
    at <unnamed> (<module>[2028]:0xcd9d0)
    at <unnamed> (<module>[2037]:0xcef38)
    at <unnamed> (<module>[43]:0x4743)
    at <unnamed> (<module>[42]:0x3fec)
    at <unnamed> (<module>[4709]:0x22985e)
    at <unnamed> (<module>[30]:0x3e58)

Additional context

The issue isn't specific to the python wapm package

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions