Skip to content

ModuleNotFoundError: No module named '_casadi' #1897

@josephjschroeder

Description

@josephjschroeder

Hi. I am frustrated by the above error, and would appreciate any insights.
Here is the backtrace, which is pretty much the same error I get when trying to debug from VS Code:

(ttc) C:\Accutils>python -i accutils_ttc.py
Traceback (most recent call last):
File "C:\Accutils\ttc\Lib\site-packages\casadi\casadi.py", line 18, in swig_import_helper
return importlib.import_module(mname)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
File "C:\Program Files\Python313\Lib\importlib_init_.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 921, in _load_unlocked
File "", line 813, in module_from_spec
File "", line 1320, in create_module
File "", line 488, in _call_with_frames_removed
ImportError: DLL load failed while importing _casadi: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Accutils\accutils_ttc.py", line 17, in
import cadquery as cq
File "C:\Accutils\ttc\Lib\site-packages\cadquery_init_.py", line 40, in
from .assembly import Assembly, Color, Constraint
File "C:\Accutils\ttc\Lib\site-packages\cadquery\assembly.py", line 22, in
from .occ_impl.solver import (
...<5 lines>...
)
File "C:\Accutils\ttc\Lib\site-packages\cadquery\occ_impl\solver.py", line 17, in
import casadi as ca
File "C:\Accutils\ttc\Lib\site-packages\casadi_init_.py", line 36, in
from casadi.casadi import *
File "C:\Accutils\ttc\Lib\site-packages\casadi\casadi.py", line 21, in
_casadi = swig_import_helper()
File "C:\Accutils\ttc\Lib\site-packages\casadi\casadi.py", line 20, in swig_import_helper
return importlib.import_module('casadi')
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
File "C:\Program Files\Python313\Lib\importlib_init
.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_casadi'

I have discovered that I can run my app by starting the python interpreter (3.13.2) like this:
"
(ttc) C:\Accutils>python
Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb 4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import casadi
import cadquery
exec(open("accutils_ttc.py").read())
"
Any ideas?

Thanks,

Joe Schroeder

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions