Pyenv problem MACOSX_DEPLOYMENT_TARGET=11.0

Having the newest operating system is a great thing, especially for all Apple fans. You know, all those fancy features, new design, fonts and so on. But unfortunately, Apple is getting worse and worse with their OSes even though the Beta tests take much time. You never know what will go wrong after the update. I faced the first problems very soon after the Big Sur installation, but most of them were not as… annoying as the problem with pyenv and python installation. Who should expect that during the installation process clang ends with “invalid version number in ‘MACOSX_DEPLOYMENT_TARGET=11.0’”?

Pyenv is a fantastic tool for maintaining multiple versions of Python. I’ve been using it for a long time and I appreciate how easy is to work with Python with that. Of course, I faced some problems with it in the past, but quite another nature (like a problem with the google-auth library)So you can imagine my anger when I discovered, that I just cannot install new Python environments! Moreover, this error is so dumb, that I couldn’t believe that it’s true! I have Big Sur, and Big Sur is the code name of Mac OS 11. Should I update the xcode? Nope, it’s in the newest version. So what should I do? Install… BETA XCode. Yeah, it’s not a joke.

invalid version number in ‘MACOSX_DEPLOYMENT_TARGET=11.0’”

Very ugly and very annoying (and no intuitive) error during the following command:

If you see something like this in the operation logs:

then you probably face the same problem as me. Take a look at the clang version:

It looks fine, but it’s not. It’s an old version taken from the XCode Command Line Tools 12.2, which probably is installed on your system. You can check which SDKs you can use by issuing this command:

As you can see, I didn’t have MacOSX11.X SDK. And that was the problem.

How to fix the problem with MACOSX_DEPLOYMENT_TARGET=11.0?

You need to install XCode Command Line Tools 12.3 Beta. Yeah, it’s that simple, however, it shouldn’t work like that. Please remember, that you don’t have to install the whole XCode, but only Command Line Tools (the entire package has over 12 GB, while CLT is just only ~500 MB). After installation you can check available SKDs one more time:

And take a look at the details – MacOSX.sdk is linked to MacOSX11.1.sdk.

Now your clang version also looks different:

Now you can install Python with pyenv without any problems. Or… you will face another one.

Cannot load such file — tzinfo

This is one of the problems you can meet. If you have old pyenv, which cannot install newer versions than for example 3.7.X, then you need to upgrade pyenv. But there is a catch. See the output:

What is the solution? Just… Install homebrew. Yeah:

Can’t decompress data; zlib not available

You are sure, that you have zlib installed in your system – by homebrew, with SDK, and with any other way. But pyenv tells that you don’t have that.

Unfortunately, you have to export some additional flags. I’m not sure at this moment if it’s a bug in pyenv or it’s caused by Big Sure itself, so treat that as a workaround, not a valid solution. Before you install the new python environment, issue the following commands:

Now everything should be ok.

And everything just because MACOSX_DEPLOYMENT_TARGET=11.0 is not included in the stable XCode Command Line Tools for MacOSX11…

Issues at GitHub pyenv

There are some issues opened in the project’s GitHub repository, so you can follow them:

4 Replies to “Pyenv problem MACOSX_DEPLOYMENT_TARGET=11.0”

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.