Skip to content

[Python] Openscad module cannot be found in any external editor or shell #6828

Description

@cravl-dev

Describe the bug
I like to do my scad in VSCode because it's much more feature rich than the built-in editor. In testing the nightly version, I wanted to try converting my current project to Python. However, I cannot find any way to access the openscad module from anywhere outside of the built-in editor. I create a virtual environment, and point the Python extension in VSCode to the venv's bin/openscad-python binary, but the type checker still says there is no openscad module. Sourcing the bin/activate script in a shell and trying to import it there gives the same error. I've looked at the code that I think loads the module and to be honest, I don't entirely understand how it works.

Is there a trick to loading the module externally, or is not possible currently?

To Reproduce
Steps to reproduce the behavior:

  1. Enable Python in settings or run with --enable python-engine --trust-python
  2. Create a virtualenv from the File > Python menu
  3. Open a shell and run:
cd <path to virtualenv>
. bin/activate
python -c 'import openscad'

Expected behavior
It should exit cleanly as it found the module and imported it successfully

Screenshots
Screenshot of test.py working in OpenSCAD
Screenshot of test.py showing module not found error in VSCode

Environment and Version info:

  • OS: KDE Neon (Ubuntu 24.04 base)
  • System: Linux Desktop, AMD64
  • OpenSCAD Version: 20260426T194550.gitb38f6888.debian-0 (APT nightly repo)

Additional context
I think installing the module into the venv's site-packages would be easier to work with, but I don't know the reasons for loading it in whatever weird way it does currently. I don't really care how it's loaded as long as working with the Python API externally is easy and intuitive. Currently it is not. 😕

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions