Node: Build: No module named 'distutils.spawn'

Created on 31 Oct 2019  路  8Comments  路  Source: nodejs/node

  • Version: master
  • Platform: WSL Ubuntu
  • Subsystem:

I know Node.js doesn't officially support Windows Subsystem for Linux, but I've been quite happily using this to develop on Windows for a while now.

Some recent change in the last week or two on master seems to be causing a build issue though as I now get the following output when running ./configure -

Traceback (most recent call last):
  File "./configure", line 20, in <module>
    from distutils.spawn import find_executable
ModuleNotFoundError: No module named 'distutils.spawn'

I have tried running git clean -fdx.

Any suggestions as to how to fix this would be a huge help to get going again here.

Python Windows Subsystem for Linux (WSL)

Most helpful comment

Another workaround

sudo apt install python3-distutils -y

All 8 comments

* **Version**: master

* **Platform**: WSL Ubuntu

* **Subsystem**:

I know Node.js doesn't officially support Windows Subsystem for Linux, but I've been quite happily using this to develop on Windows for a while now.

Some recent change in the last week or two on master seems to be causing a build issue though as I now get the following output when running ./configure -

Traceback (most recent call last):
  File "./configure", line 20, in <module>
    from distutils.spawn import find_executable
ModuleNotFoundError: No module named 'distutils.spawn'

I have tried running git clean -fdx.

Any suggestions as to how to fix this would be a huge help to get going again here.

The recent change is most likely https://github.com/nodejs/node/pull/30091 which now prefers Python 3 for configure. https://github.com/pypa/pipenv/issues/2922#issuecomment-427334335 suggests a bug in Ubuntu's version of Python.

A workaround would be to specify the version of Python used to run configure: python2 configure.py or python2.7 configure.py

Another workaround

sudo apt install python3-distutils -y

@gengjiawen If python3-distutils is a required dep of our built for py3, it'd be really helpful if you could PR that to BUILDING.md, if you have time.

I can confirm sudo apt install python3-distutils -y fixed the issue here. Thanks so much for the quick responses. Shall I keep this open to track the documentation change?

@guybedford @sam-github I will try to add this to documentation, leave this open for now :)

The other solution seems to be python3 -m pip install setuptools.

Linux users

If;
sudo apt install python3-distutils -y;
didn't work for you, ensure you have installed venv globally that corresponds to your python version i.e

your_com:~$sudo apt install python3.9-venv
your_comp:~/Desktop/your_prj$virtualenv venv --python=python3.9

distutils is being phased out as explained at https://docs.python.org/3/installing

Python 3.3 and later has a builtin venv module https://docs.python.org/3/library/venv.html so virtualenv is not required and you can:

python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
[ ... ]
deactivate
Was this page helpful?
0 / 5 - 0 ratings

Related issues

cong88 picture cong88  路  3Comments

vsemozhetbyt picture vsemozhetbyt  路  3Comments

Brekmister picture Brekmister  路  3Comments

willnwhite picture willnwhite  路  3Comments

Icemic picture Icemic  路  3Comments