Install error: ModuleNotFoundError: No module named ‘distutils.spawn’

  • Version: v15.11.0
  • Platform: Ubuntu 20.04
  • Subsystem: ?

What steps will reproduce the bug?

Install nodejs with nvm:

nvm install stable

How often does it reproduce? Is there a required condition?

Appears to occur every time on a fresh Ubuntu 20.04 docker image.

What is the expected behavior?

NodeJS installs successfully.

What do you see instead?

$ nvm install stable
Downloading and installing node v15.11.0...
Downloading https://nodejs.org/dist/v15.11.0/node-v15.11.0-linux-x64.tar.xz...
################################################################################################################################################### 100.0%%
Computing checksum with sha256sum
Checksums matched!
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Child returned status 141
tar: Error is not recoverable: exiting now
Binary download failed, trying source.
Detected that you have 6 CPU core(s)
Running with 5 threads to speed up the build
Downloading https://nodejs.org/dist/v15.11.0/node-v15.11.0.tar.xz...
################################################################################################################################################### 100.0%%
Computing checksum with sha256sum
Checksums matched!
$>./configure --prefix=/home/vscode/.nvm/versions/node/v15.11.0 <
Traceback (most recent call last):
  File "./configure", line 21, in <module>
    from distutils.spawn import find_executable
ModuleNotFoundError: No module named 'distutils.spawn'
nvm: install v15.11.0 failed!

Then after a second run on the same machine with no changes.

$ nvm install stable
Downloading and installing node v15.11.0...
Local cache found: ${NVM_DIR}/.cache/bin/node-v15.11.0-linux-x64/node-v15.11.0-linux-x64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v15.11.0-linux-x64/node-v15.11.0-linux-x64.tar.xz
Now using node v15.11.0 (npm v7.6.0)
Creating default alias: default -> stable (-> v15.11.0)

Additional information

There was some previous discussion about this issue with Ubuntu 18.04 where it was suggested to install sudo apt install python3-distutils -y, but even without that installed the second attempt to install succeeds successfully, so it seems like something else is going on.

1 possible answer(s) on “Install error: ModuleNotFoundError: No module named ‘distutils.spawn’