Skip to content

ModuleNotFoundError: No module named '_posixshmem' when using multiprocessing #6038

@WallPasq

Description

@WallPasq

Summary

When attempting to run a Python script that utilizes the multiprocessing module, RustPython fails with a ModuleNotFoundError. The interpreter cannot find the _posixshmem module, which seems to be a dependency for the multiprocessing library's resource tracker on POSIX systems.

Expected

The script should execute without raising a ModuleNotFoundError, allowing the multiprocessing.Process to start and run the target function.

Actual

--- Testing: (simple_recursive_fibonacci) ---
Traceback (most recent call last):
  File "src/main.py", line 149, in <module>
    name, n, num_digits = performance_tester(func)
  File "src/main.py", line 95, in performance_tester
    median_runtime: float = time_execution(n)
  File "src/main.py", line 75, in time_execution
    process.start()
  File "/Users/wallacy/.cargo/git/checkouts/rustpython-63090cdce5e18442/4079776/pylib/Lib/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/Users/wallacy/.cargo/git/checkouts/rustpython-63090cdce5e18442/4079776/pylib/Lib/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/Users/wallacy/.cargo/git/checkouts/rustpython-63090cdce5e18442/4079776/pylib/Lib/multiprocessing/context.py", line 289, in _Popen
    return Popen(process_obj)
  File "/Users/wallacy/.cargo/git/checkouts/rustpython-63090cdce5e18442/4079776/pylib/Lib/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/Users/wallacy/.cargo/git/checkouts/rustpython-63090cdce5e18442/4079776/pylib/Lib/multiprocessing/popen_fork.py", line 20, in __init__
    self._launch(process_obj)
  File "/Users/wallacy/.cargo/git/checkouts/rustpython-63090cdce5e18442/4079776/pylib/Lib/multiprocessing/popen_spawn_posix.py", line 39, in _launch
    from . import resource_tracker
  File "/Users/wallacy/.cargo/git/checkouts/rustpython-63090cdce5e18442/4079776/pylib/Lib/multiprocessing/resource_tracker.py", line 42, in <module>
    import _posixshmem
ModuleNotFoundError: No module named '_posixshmem'

System Information

  • OS: macOS Monterey 12.7.6
  • RustPython Version:
Python 3.13.0alpha (heads/master:4079776c3, Jul 25 2025, 12:42:22) 
[RustPython 0.4.0 with rustc 1.88.0 (6b00bc388 2025-06-23)]

Code to Reproduce

Fibonacci

Just download the file and run it.

rustpython main.py

Update - 2025-07-25 21:39 UTC

I just tested it in Docker with the Arch Linux image and it worked perfectly. I used the following commands:

docker run -it --rm archlinux:base-devel-20250720.0.386825 bash
pacman -Syu git
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
cargo install --git https://github.com/RustPython/RustPython rustpython
git clone https://github.com/WallPasq/fibonacci.git
rustpython fibonacci/src/main.py

However, it still doesn't work on macOS, so I don't think the issue is hardware-related.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions