# Python cannot find module

**URL:** <https://discuss.python.org/t/python-cannot-find-module/39058>\
**Category:** Python Help\
**Created:** [November 18, 2023, 4:47pm UTC](https://discuss.python.org/t/python-cannot-find-module/39058 "2023-11-18T16:47:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_hedegar](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@M\_hedegar](https://discuss.python.org/u/M_hedegar)\
**Post date:** [November 18, 2023, 4:47pm UTC](https://discuss.python.org/t/python-cannot-find-module/39058/1 "2023-11-18T16:47:29Z")

</div>

Hi,

I am new to Python. I need to install the package Casadi. I tried this and was told that I need the package or module cmake. Fine, so I installed cmake (pip install cmake) and “cmake --version” now produces  
_make version 3.27.7_  
_CMake suite maintained and supported by Kitware ([kitware.com/cmake](http://kitware.com/cmake))._  
However, it seems that Python cannot find cmake because “pip install Casadi” produces the following error message

_× Building wheel for casadi (pyproject.toml) did not run successfully._

- │ exit code: 1\*
- ╰─\> [64 lines of output]\*
- **:** \*
- 

```
    File "C:\Users\mhedegar\AppData\Local\Programs\Python\Python312\Scripts\cmake.exe\ __main__.py", line 4, in <module>*

```

- 

```
 ModuleNotFoundError: No module named 'cmake'*

```

- 

```
 Traceback (most recent call last):*

```

_ **:** _

- 

```
 [end of output]*

```

- note: This error originates from a subprocess, and is likely not a problem with pip.\*
- ERROR: Failed building wheel for casadi\*  
_Failed to build casadi_  
_ERROR: Could not build wheels for casadi, which is required to install pyproject.toml-based projects_

I have used : to denote that there are more lines which I have excluded. Please tell me if you want to see more details in the error message.

I am course very thankful for help. I really don’t know where to start.

BR

/Marcus

---

<div class="post-metadata">

**Author:** ![rob42](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rob42/32/8218_2.png) [@rob42](https://discuss.python.org/u/rob42)\
**Post date:** [November 18, 2023, 9:21pm UTC](https://discuss.python.org/t/python-cannot-find-module/39058/2 "2023-11-18T21:21:42Z")

</div>

@M_hedegar

It’s possible that someone here will know what the issue is and you could get a better reply than this one, but have you tried [the CasADi Support Community](https://web.casadi.org/support/), given that the issue may very well be with the package, rather than with your Python environment.

---

<div class="post-metadata">

**Author:** ![M\_hedegar](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@M\_hedegar](https://discuss.python.org/u/M_hedegar)\
**Post date:** [November 18, 2023, 10:09pm UTC](https://discuss.python.org/t/python-cannot-find-module/39058/3 "2023-11-18T22:09:33Z")

</div>

Thank you Rob. It’s a good suggestion and I will try it. I hadn’t thought about the possibility that problem was within casadi.

Yet, if someone here has even more insight, please still respond.

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [November 19, 2023, 12:49am UTC](https://discuss.python.org/t/python-cannot-find-module/39058/4 "2023-11-19T00:49:32Z")

</div>

> [@M\_hedegar](#):
>
> `C:\Users\mhedegar\AppData\Local\Programs\Python\Python312\Scripts\cmake.exe\ __main__.py`

This is suspicious. It seems as if the Casadi installer is trying to `import` CMake as a Python package, but looking for it in the `Scripts` folder which is for wrapper executables (to offer a command-line interface like when you tried `cmake --version`). Normally, packages that you install from PyPI (using Pip) are supposed to specify their dependencies (i.e. Casadi would specify CMake), and Pip would automatically install them first - so you shouldn’t need to run a separate command, although it also shouldn’t cause a problem.

Casadi doesn’t seem to be open-source (and I’m currently having trouble trying to load the website), so I can’t really investigate any further than that. But I’m willing to agree that it is likely their fault, and their support ticket.

(I hope Python is not your first programming language; otherwise “a symbolic framework for numeric optimization implementing automatic differentiation in forward and reverse modes on sparse matrix-valued computational graphs” (per the PyPI description) might not be the best place to start learning programming 🙂 )

---

<div class="post-metadata">

**Author:** ![M\_hedegar](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@M\_hedegar](https://discuss.python.org/u/M_hedegar)\
**Post date:** [November 19, 2023, 6:03am UTC](https://discuss.python.org/t/python-cannot-find-module/39058/5 "2023-11-19T06:03:51Z")

</div>

Hi Karl! Good point I think. It’s good to be able to narrow it down to Casadi.I may try to install a completely different package which requires cmake to test this hypothesis.

I have 15 years of experience programming in Matlab. I have encountered Casadi as an add on to- Matlab, but I have almost not used it. The description sounds scary, I agree 🙂 Now, I need Casadi to simulate electric vehicle batteries with PyBaMM.

---

<div class="post-metadata">

**Author:** ![M\_hedegar](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@M\_hedegar](https://discuss.python.org/u/M_hedegar)\
**Post date:** [November 19, 2023, 4:36pm UTC](https://discuss.python.org/t/python-cannot-find-module/39058/6 "2023-11-19T16:36:24Z")

</div>

The problem was resolved. I thought of the possibility that cmake is a broader application than just for Python. That is the case. So I downloaded and installed this broader application from “cmake” homepage. Then it worked. I have a very vague memory of having to do this before on an old computer. Possibly for using casadi in Matlab.
