Fixing clang error: invalid version number in MACOSX_DEPLOYMENT_TARGET

clang error: invalid version number in MACOSX_DEPLOYMENT_TARGET is an error which occurs when an old clang version has been installed on your system and sometimes for other reasons.

I will explain why this error is taking place and how to fix it, while also trying to add other solutions that could help us solve the problem.

Exploring the clang error: invalid version number in MACOSX_DEPLOYMENT_TARGET

This is an error which occurs when an old clang version has been installed on your system and sometimes for other reasons.

Please make sure the error message looks like the error message bellow after double checking. Do not mix between errors.

                                                                       #
clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11.0'
                                                                       #

The method that fixed the problem for me : switch to the latest version of xcode-selec

The first fix to your issue is setting the xcode-select to its latest version.

xcode-select is a command-line tool that is installed in /usr/bin

First, you should navigate to this link: https://idmsa.apple.com/IDMSWebAuth/ and install the latest Command Line Tools.

Finally, go ahead and set the xcode-select to its latest version using the command bellow.

                                                                       #
sudo xcode-select --switch /Library/Developer/CommandLineTools
                                                                       #

The main issue that this is going to fix is that the oldest versions xcode-select installs an unsupported version of clang which is why we have the error we are trying to solve.

If the above does not work, try the command bellow

                                                                       #
sudo rm -rf /Library/Developer/CommandLineTools
                                                                       #

Then install xcode-select, using : sudo xcode-select –install

After trying all the above, if the error persisted. Try this

                                                                       #
export SYSTEM_VERSION_COMPAT=1
                                                                       #

After following the instructions above, your error should be solved, please try the method bellow if that is not the case.

I hope this guide solved your problem, thank you for reading and reaching the end of this blog post.

Summing-up : 

This is the end of our post, I hope this has been helpful and helped you solve the error or at least pointed you in the right direction.

Thank you for reading, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/