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:
1 |
$ pyenv install 3.8.5 |
If you see something like this in the operation logs:
1 2 3 4 5 6 |
making all in crypto... /usr/bin/perl ../util/mkbuildinf.pl "clang -I. -I.. -I../include -fPIC -fno-common -DOPENSSL_PIC -DZLIB_SHARED -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM" "darwin64-x86_64-cc" >buildinf.h clang -I. -I.. -I../include -fPIC -fno-common -DOPENSSL_PIC -DZLIB_SHARED -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -I/Users/amph/.pyenv/versions/3.5.0/openssl/include -I/Users/amph/.pyenv/versions/3.5.0/include -c -o cryptlib.o cryptlib.c clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11.0' make[1]: *** [cryptlib.o] Error 1 make: *** [build_crypto] Error 1 |
then you probably face the same problem as me. Take a look at the clang version:
1 2 3 4 5 |
$ clang --version Apple clang version 11.0.0 (clang-1100.0.33.8) Target: x86_64-apple-darwin20.1.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin |
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:
1 2 |
$ ls /Library/Developer/CommandLineTools/SDKs MacOSX.sdk MacOSX10.14.sdk MacOSX10.15.sdk |
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:
1 2 |
$ ls /Library/Developer/CommandLineTools/SDKs MacOSX.sdk MacOSX10.14.sdk MacOSX10.15.sdk MacOSX11.1.sdk |
And take a look at the details – MacOSX.sdk is linked to MacOSX11.1.sdk.
Now your clang version also looks different:
1 2 3 4 5 |
$ clang --version Apple clang version 12.0.0 (clang-1200.0.32.28) Target: x86_64-apple-darwin20.1.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin |
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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
$ brew upgrade pyenv Updating Homebrew... Traceback (most recent call last): 16: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `<main>' 15: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `require_relative' 14: from /usr/local/Homebrew/Library/Homebrew/global.rb:18:in `<top (required)>' 13: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 12: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 11: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/numeric/time.rb:4:in `<top (required)>' 10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 8: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/time/calculations.rb:4:in `<top (required)>' 7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 5: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/time/conversions.rb:4:in `<top (required)>' 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 2: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/values/time_zone.rb:3:in `<top (required)>' 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- tzinfo (LoadError) Traceback (most recent call last): 16: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `<main>' 15: from /usr/local/Homebrew/Library/Homebrew/brew.rb:31:in `require_relative' 14: from /usr/local/Homebrew/Library/Homebrew/global.rb:18:in `<top (required)>' 13: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 12: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 11: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/numeric/time.rb:4:in `<top (required)>' 10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 8: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/time/calculations.rb:4:in `<top (required)>' 7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 5: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/core_ext/time/conversions.rb:4:in `<top (required)>' 4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' 2: from /usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.0.3.4/lib/active_support/values/time_zone.rb:3:in `<top (required)>' 1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- tzinfo (LoadError) |
What is the solution? Just… Install homebrew. Yeah:
1 |
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" |
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.
1 2 3 4 5 6 7 8 9 10 11 |
Last 10 log lines: mod_name, mod_spec, code = _get_module_details(mod_name) File "/private/var/folders/7c/8z4_2y4971g82k82jktlf1sh0000gn/T/python-build.20201123110819.75739/Python-3.8.5/Lib/runpy.py", line 144, in _get_module_details return _get_module_details(pkg_main_name, error) File "/private/var/folders/7c/8z4_2y4971g82k82jktlf1sh0000gn/T/python-build.20201123110819.75739/Python-3.8.5/Lib/runpy.py", line 111, in _get_module_details __import__(pkg_name) File "<frozen zipimport>", line 241, in load_module File "<frozen zipimport>", line 709, in _get_module_code File "<frozen zipimport>", line 570, in _get_data zipimport.ZipImportError: can't decompress data; zlib not available make: *** [install] Error 1 |
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:
1 2 |
$ export LDFLAGS="-L/usr/local/opt/zlib/lib" $ export CPPFLAGS="-I/usr/local/opt/zlib/include" |
Now everything should be ok.
1 2 3 4 5 6 7 8 9 |
$ pyenv install 3.8.5 python-build: use openssl@1.1 from homebrew python-build: use readline from homebrew Downloading Python-3.8.5.tar.xz... -> https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz Installing Python-3.8.5... python-build: use readline from homebrew python-build: use zlib from xcode sdk Installed Python-3.8.5 to /Users/amph/.pyenv/versions/3.8.5 |
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:
and you need a developer’s account to download the beta version of the command line tools.
Yes, but not the paid one. 🙂 you just need to log into the Developer portal with your Apple ID and that’s it.
Emil, may I ask you a dumb question:
how can I tell which MACOSX_DEPLOYMENT_TARGET a .dylib was built with ?
Can you comment on https://github.com/scipy/scipy/issues/9858 —
how to debug scipy -> .dylibs which segfaults on my old 10.10 ?
Thanks !
Awesome solution – even not found on Stackoverflow.com 🙂
Thanks a ton for writing the solution here.