简体   繁体   中英

Pyenv and Python 3.9.1. - BUILD FAILED on Big Sur

I appreciate there are tons of this messages around, and I read a few since last year when I first attempted the installation of the 3.9.0. The most recent ones with some kind of additional hints:

No matter what kind of environment variable I set, whether the XCode is update to the most recent 12.5 or stick to the 12.3 (which HomeBrew packages reports as obsolete), I still can't get pyenv installing the 3.9.1.

Homebrew, on the other end has the 3.9.1 and 3.9.5 installed so somehow the compilers are in place and are working.

The most recent attempt I gave is using the following environment variables:

export MACOSX_DEPLOYMENT_TARGET="$(sw_vers -productVersion | cut -c -5)"
export LIBRARY_PATH="$(brew --prefix openssl)/lib:${LIBRARY_PATH}"
export PYTHON_CONFIGURE_OPTS="--enable-framework
export PYTHON_CONFIGURE_OPTS="--with-openssl=$(brew --prefix openssl) ${PYTHON_CONFIGURE_OPTS}"

export LDFLAGS="-L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" 
export CPPFLAGS="-I$(brew --prefix zlib)/include -I$(brew --prefix bzip2)/include" 
export CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix zlib)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" 
export LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib"

The following error message appears, consistently.

BUILD FAILED (OS X 11.4 using python-build 20180424)

Inspect or clean up the working tree at /var/folders/c_/ll8fp86d39d2qthh_cbg8vlc0000gp/T/python-build.20210701193101.41835
Results logged to /var/folders/c_/ll8fp86d39d2qthh_cbg8vlc0000gp/T/python-build.20210701193101.41835.log

Last 10 log lines:
checking for python3.9... python3.9
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... "darwin"
checking for gcc... gcc-10
checking whether the C compiler works... no
configure: error: in `/var/folders/c_/ll8fp86d39d2qthh_cbg8vlc0000gp/T/python-build.20210701193101.41835/Python-3.9.1':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

What makes me suspicious is the last line, that is slightly different from other post similar to mine. Or the one where it says "C compiler cannot create executables" which I thought it was linked to iTerm not having full Disk permissions, which is not the case.

I don't have a clue of what this target is, that's why I thought the above export could have helped, but that's not the case. Some sites suggest the necessity to run a make, which I expect pyenv to do, but then fact there is not a makefile (I assume a CMakeLists.txt) is again opening to a whole new set of problems.

Is there anybody that has experienced the same or could help me figuring this out?

-- UPDATE Config file gist available here Just noticed that when I do a pyenv which gcc the output says /usr/bin/gcc. Given that CommandLine Tools and/or HomeBrew gcc should be used, couldn't this be the cause of the problems?

I had a revelation while editing this post before.

It turns out that I completely forgot to have a look at my ~/.zshrc file. The latter included a CC and CXX environment variables set respectively to gcc-10 and g++-10 to let Facebook Prophet work. GCC-10 was no longer available though for whatever reason, I guess HomeBrew updated it to gcc-11 somehow.

Overriding the environment variables at command line while invoking the installation solved the problem.

For whoever might find this useful, that's the invocation line including the enviroment variables I used:

env \
  LDFLAGS="-L$(brew --prefix xz)/lib -L$(brew --prefix openssl)/lib  -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib -L$(brew --prefix readline)/lib " \
  CPPFLAGS="-I$(brew --prefix zlib)/include -I$(brew --prefix bzip2)/include" \
  CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix zlib)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include -I$(brew --prefix xz)/include" \
  CXX=g++-11 \
  CC=gcc-11 \
  pyenv install 3.9.1

I have some doubts on the necessity of all of them, as well as the correctness.

For instance, to date I still not understand the difference between -I or -L flag, and I couldn't find anywhere the answer. If you have the answer, feel free to post a comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM