If you get this type of errors TypeError: can_build() takes 1 positional argument but 2 were given when trying to compile Godot you have to do this :

When i tried to compile with scons i got this errors :
scons: Reading SConscript files ... Automatically detected platform: osx Building for macOS 10.12+, platform x86-64. TypeError: can_build() takes 1 positional argument but 2 were given: File "/Users/myuser/godot/SConstruct", line 556: if config.can_build(env, selected_platform):
How to solve this error ?
First check you version of scons by launching :
scons -v
It will give you the scons path :
SCons path: ['/usr/local/Cellar/scons/4.1.0.post1/libexec/lib/python3.9/site-packages/SCons']
You then notice the use of python 3.9
You have to update your python to 3.9 :
Update Python easy update to Python 3.9 with homebrew – To update Mac os python from an older version to the latest python example python 3.9.1 you can do the folowing :
This article briefly describes how to replace its version of python on Mac. I wrote a similar article some time ago.

I used Homebrew to get the latest python as describe on https://formulae.brew.sh/formula/python@3.9:
brew install python@3.9
python --version Python 3.8.5 python3 --version Python 3.8.5
You see that it stays on the older version.
Detect where python or python3 is setup
I had to first verify where my python command is pointing, by launching :
which python
It gave me in my case:
/Users/myuser/.pyenv/shims/python
You need also to verify where is python3 command if you have different versions :
which python3
I get :
/Users/myuser/.pyenv/shims/python3
Replace the version
I need to replace the version of the both command python and python3 by launching :
ln -s -f /usr/local/bin/python3.9 /Users/myuser/.pyenv/shims/python3
And also launch :
ln -s -f /usr/local/bin/python3.9 /Users/myuser/.pyenv/shims/python
The you can test it works :
python --version Python 3.9.1 python3 --version Python 3.9.1
Come back on GODOT compilation with Scons :
You need to localize the module that is bad in GODOT modules directory
For example i localize speech_to_text that was bad in config.py
So i directly modify config.py from this directory from can_build(env) to can_build(env, platform):
import os # system() def can_build(env, platform): if platform == "x11": has_pulse = os.system("pkg-config --exists libpulse-simple") == 0 has_alsa = os.system("pkg-config --exists alsa") == 0 return has_pulse or has_alsa elif platform in ["windows", "osx", "iphone", "android"]: return True else: return False def configure(env): pass
And it works :
godot % scons scons: Reading SConscript files ... Automatically detected platform: osx Building for macOS 10.12+, platform x86-64. YASM is necessary for WebM SIMD optimizations. WebM SIMD optimizations are disabled. Check if your CPU architecture, CPU bits or platform are supported! Checking for C header file mntent.h... no scons: done reading SConscript files. scons: Building targets ... [Initial build] Compiling ==> platform/osx/crash_handler_osx.mm [Initial build] Compiling ==> platform/osx/os_osx.mm [Initial build] Building RD_GLSL header: "servers/rendering/renderer_rd/shaders/canvas.glsl.gen.h" [Initial build] Building RD_GLSL header: "servers/rendering/renderer_rd/shaders/canvas_occlusion.glsl.gen.h" [Initial build] Building RD_GLSL header: "servers/rendering/renderer_rd/shaders/scene_forward.glsl.gen.h" [Initial build] Building RD_GLSL header: "servers/rendering/renderer_rd/shaders/canvas_sdf.glsl.gen.h"
TypeError: can_build() takes 1 positional argument but 2 were given – Internal links :
This article briefly describes how to replace its version of python on Mac. I wrote a similar article some time ago.