'python3.EXE is not a valid python or it is missing distutils' error when installing PyGObject in Windows
I'm really really curious about this error. I can't find this anywhere in the issues list, tried searching here, came up with 0 results.
So, I was trying to install PyGObject within Windows, and what's odd is that I am using a Python version that supports distutils. I can't use Python 3.12 because distutils was removed in that version and many projects still rely on that distutils module and not setuptools module and would give the ModuleNotFoundError: No module named 'distutils'
error.
Anyways, back to what I was saying. When I attempt to install PyGObject in Windows under Python 3.10.7, this error occurs:
meson.build:16:15: ERROR: <PythonExternalProgram 'python3' -> ['C:\\msys64\\usr\\bin\\python3.EXE']> is not a valid python or it is missing distutils
Here's the full log:
Building project pygobject (3.46.0)
The Meson build system
Version: 1.3.0
Source dir: C:\gtk-build\build\x64\release\pygobject
Build dir: C:\gtk-build\build\x64\release\pygobject\_gvsbuild-meson
Build type: native build
Project name: pygobject
Project version: 3.46.0
C compiler for the host machine: cl (msvc 19.38.33134 "Microsoft (R) C/C++ Optimizing Compiler Version 19.38.33134 for x64")
C linker for the host machine: link link 14.38.33134.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
meson.build:16:15: ERROR: <PythonExternalProgram 'python3' -> ['C:\\msys64\\usr\\bin\\python3.EXE']> is not a valid python or it is missing distutils
A full log can be found at C:\gtk-build\build\x64\release\pygobject\_gvsbuild-meson\meson-logs\meson-log.txt
Traceback (most recent call last):
File "C:\Users\Silve\AppData\Local\pipx\pipx\venvs\gvsbuild\lib\site-packages\gvsbuild\utils\builder.py", line 527, in build
if self.__build_one(p):
File "C:\Users\Silve\AppData\Local\pipx\pipx\venvs\gvsbuild\lib\site-packages\gvsbuild\utils\builder.py", line 663, in __build_one
skip_deps = proj.build()
File "C:\Users\Silve\AppData\Local\pipx\pipx\venvs\gvsbuild\lib\site-packages\gvsbuild\projects\pygobject.py", line 41, in build
Meson.build(self)
File "C:\Users\Silve\AppData\Local\pipx\pipx\venvs\gvsbuild\lib\site-packages\gvsbuild\utils\base_builders.py", line 47, in build
self._setup_meson_and_ninja(ninja_build, meson_params, add_path)
File "C:\Users\Silve\AppData\Local\pipx\pipx\venvs\gvsbuild\lib\site-packages\gvsbuild\utils\base_builders.py", line 79, in _setup_meson_and_ninja
self.exec_vs(cmd, add_path=add_path)
File "C:\Users\Silve\AppData\Local\pipx\pipx\venvs\gvsbuild\lib\site-packages\gvsbuild\utils\base_project.py", line 192, in exec_vs
self.builder.exec_vs(
File "C:\Users\Silve\AppData\Local\pipx\pipx\venvs\gvsbuild\lib\site-packages\gvsbuild\utils\builder.py", line 937, in exec_vs
self.__execute(
File "C:\Users\Silve\AppData\Local\pipx\pipx\venvs\gvsbuild\lib\site-packages\gvsbuild\utils\builder.py", line 1041, in __execute
subprocess.check_call(args, cwd=working_dir, env=env, shell=True)
File "C:\Users\Silve\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command 'C:\Users\Silve\AppData\Local\pipx\pipx\venvs\gvsbuild\Scripts\python.exe C:\gtk-build\tools\meson-1.3.0\meson.py setup C:\gtk-build\build\x64\release\pygobject C:\gtk-build\build\x64\release\pygobject\_gvsbuild-meson --prefix C:\gtk-build\gtk\x64\release --buildtype debugoptimized' returned non-zero exit status 1.
Error: pygobject build failed
Surely I must be missing something. Something very important that's required for building PyGObject, right?
I took a look in the log, and this is what it shows at the very end:
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: x86_64
Target machine cpu: x86_64
Could not introspect Python (['C:\\msys64\\usr\\bin\\python3.EXE', 'C:\\gtk-build\\tools\\meson-1.3.0\\mesonbuild\\scripts\\python_info.py']): exit code 2
Program stdout:
Program stderr:
/usr/bin/python3.exe: can't open file '/c/gtk-build/build/x64/release/pygobject/C:\\gtk-build\\tools\\meson-1.3.0\\mesonbuild\\scripts\\python_info.py': [Errno 2] No such file or directory
meson.build:16:15: ERROR: <PythonExternalProgram 'python3' -> ['C:\\msys64\\usr\\bin\\python3.EXE']> is not a valid python or it is missing distutils
I should note that I can install PyGObject successfully in msys2 terminal by following the guide here, however I can't install PyGObject via pip or gvsbuild on Windows in PowerShell 7, and even can't install it via pip on the msys2 terminal.
So I'm really curious, what am I missing? meson-log.txt