Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named cmake

When I run the command

cmake --version

It gives me the version. But when I run

import cmake

It gives the error cmake module not present.

I am stuck and not getting how to resolve it

like image 813
NITIKA KHATKAR Avatar asked Sep 06 '25 03:09

NITIKA KHATKAR


2 Answers

For me on MacOSX when I initially install CMake by pip, it goes to the similar behaviour.

It was solved by uninstalling CMake by pip, and installing CMake first by brew before installing by pip, and before it installing brew itself, by running in terminal commands from How to run CMake in Mac? answer.

like image 109
Nashev Avatar answered Sep 08 '25 19:09

Nashev


You are talking about two different things:

  1. When running cmake --version, you are calling the command line program CMake
  2. When using import cmake in a Python program (or interactive session) you are using the cmake Python module.

You are missing the second one. You can install it, e.g. by calling

pip install cmake
like image 40
mrhd Avatar answered Sep 08 '25 20:09

mrhd