Cyberithub

Solved: ModuleNotFoundError: No module named 'skbuild'

Advertisements

In this article, we will see how to solve ModuleNotFoundError: No module named 'skbuild' error if you are also getting this one. Last night when I was working on a Python project and trying to run my program, I noticed that my program was throwing ModuleNotFoundError: No module named 'skbuild' error. While this error was unexpected to me but after checking for few mins I understood the reason for this error. So before solving the error I decided to write an article about this so that it will help you guys also in case you are also facing the same error.

Solved: ModuleNotFoundError: No module named 'skbuild'

Solved: ModuleNotFoundError: No module named 'skbuild'

Also Read: Solved: ModuleNotFoundError: No module named 'sklearn' in Python3

When I was trying to use Scikit-build package in my Python setup.py program, then I noticed that it was failing with ModuleNotFoundError: No module named 'skbuild' error as you can see below.

NOTE:

Please note that in my case I am using Ubuntu 20.04 LTS System with Python3 installed. This could be different for you. You could be using some different System with different version of python installed.
cyberithub@ubuntu:~$ python3 setup.py build_ext --inplace
Traceback (most recent call last):
File "setup.py", line 1, in <module>
from skbuild import setup
ModuleNotFoundError: No module named 'skbuild'

While above error could occur due to multiple reasons but in most of the cases it is due to missing Python Scikit-build package. So if you have pip utility available in your System then you can easily install the package by using pip3 install scikit-build command as shown below.

cyberithub@ubuntu:~$ pip3 install scikit-build
Collecting scikit-build
Downloading scikit_build-0.15.0-py2.py3-none-any.whl (77 kB)
|████████████████████████████████| 77 kB 2.1 MB/s
Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from scikit-build) (20.3)
Requirement already satisfied: distro in /usr/lib/python3/dist-packages (from scikit-build) (1.4.0)
Requirement already satisfied: wheel>=0.29.0 in /usr/lib/python3/dist-packages (from scikit-build) (0.34.2)
Requirement already satisfied: setuptools>=28.0.0; python_version >= "3" in /usr/lib/python3/dist-packages (from scikit-build) (45.2.0)
Installing collected packages: scikit-build
Successfully installed scikit-build-0.15.0

Alternatively, you can also choose to install scikit-build module from source by first cloning the repo from GitHub using git clone https://github.com/scikit-build/scikit-build command as shown below.

cyberithub@ubuntu:~$ git clone https://github.com/scikit-build/scikit-build
Cloning into 'scikit-build'...
remote: Enumerating objects: 5806, done.
remote: Counting objects: 100% (1387/1387), done.
remote: Compressing objects: 100% (697/697), done.
remote: Total 5806 (delta 859), reused 1075 (delta 626), pack-reused 4419
Receiving objects: 100% (5806/5806), 1.78 MiB | 5.88 MiB/s, done.
Resolving deltas: 100% (3719/3719), done.

Then switched to directory scikit-build by using cd scikit-build command.

cyberithub@ubuntu:~$ cd scikit-build

Then install the package using pip3 install . command as shown below.

cyberithub@ubuntu:~/scikit-build$ pip3 install .
Processing /home/cyberithub/scikit-build
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing wheel metadata ... done
Requirement already satisfied: wheel>=0.32.0 in /usr/lib/python3/dist-packages (from scikit-build==0.15.1.dev30+g82a22c3) (0.34.2)
Requirement already satisfied: distro in /usr/lib/python3/dist-packages (from scikit-build==0.15.1.dev30+g82a22c3) (1.4.0)
Requirement already satisfied: packaging in /usr/lib/python3/dist-packages (from scikit-build==0.15.1.dev30+g82a22c3) (20.3)
Requirement already satisfied: setuptools>=42.0.0 in /usr/lib/python3/dist-packages (from scikit-build==0.15.1.dev30+g82a22c3) (45.2.0)
Building wheels for collected packages: scikit-build
Building wheel for scikit-build (PEP 517) ... done
Created wheel for scikit-build: filename=scikit_build-0.15.1.dev30+g82a22c3-py3-none-any.whl size=50356 sha256=02e889cf166dd12830aacd2ad66b85cc2c239c3bbfa39b8f884b3176bdba8674
Stored in directory: /home/cyberithub/.cache/pip/wheels/8c/d3/e6/4bc7b7d66d2c8e7e63e9ccfb4d5e3f95fdd4ce9f708158c2b2
Successfully built scikit-build
Installing collected packages: scikit-build
Successfully installed scikit-build-0.15.1.dev30+g82a22c3

After successfully installing the module, I tried running my python program again and this time I noticed that it ran successfully without any error as you can also see below.

cyberithub@ubuntu:~$ python3 setup.py build_ext --inplace


--------------------------------------------------------------------------------
-- Trying "Ninja" generator
--------------------------------
---------------------------
............................................

This confirms that my error was due to missing scikit-build module in my System. But this might not be always the case. You might get ModuleNotFoundError: No module named 'skbuild' error even if you have the scikit-build module installed in your System. In those cases, usually the error occurs because module is installed in a place which is not visible to your System. So to make that module visible across the system, you need to export the location in PATH environment variable.

Hope, above solution would help you solve ModuleNotFoundError: No module named 'skbuild' error. Please let me know your feedback in the comment box.

Leave a Comment