Pyenv build failed solution

Today, I have a headache caused by the Chinese problem of python2. X. I found that python3. X supports Chinese very well, but I am worried that some packages do not support the version of python3. We use pyenv to manage python.

Operating system: OSX 10.11

First of all, I used homebrew to install pyenv. In this step, I saw some mistakes on the Internet, and then how to solve them. Fortunately, I didn’t make any mistakes here. I thought it would be over. Here’s the problem

Problem: when using pyenv install 3.4.1, the following problems occurred after downloading

Downloading Python-3.4.1.tgz...-https://yyuu.github.io/pythons/44a3c1ef1c7ca3e4fd25242af80ed72da941203cb4ed1a8c1b724d9078965dd8
Installing Python-3.4.1...

BUILD FAILED (OS X 10.9.5 using python-build 20150124)

Inspect or clean up the working tree at /var/folders/zf/1b6kcyd53hg0crv65j108_7m0000gn/T/python-build.20150127150918.87726
Results logged to /var/folders/zf/1b6kcyd53hg0crv65j108_7m0000gn/T/python-build.20150127150918.87726.log

Last 10 log lines:
  File "/private/var/folders/zf/1b6kcyd53hg0crv65j108_7m0000gn/T/python-build.20150127150918.87726/Python-3.4.1/Lib/ensurepip/__main__.py", line 4, in <module>
    ensurepip._main()
  File "/private/var/folders/zf/1b6kcyd53hg0crv65j108_7m0000gn/T/python-build.20150127150918.87726/Python-3.4.1/Lib/ensurepip/__init__.py", line 209, in _main
    default_pip=args.default_pip,
  File "/private/var/folders/zf/1b6kcyd53hg0crv65j108_7m0000gn/T/python-build.20150127150918.87726/Python-3.4.1/Lib/ensurepip/__init__.py", line 116, in bootstrap
    _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/private/var/folders/zf/1b6kcyd53hg0crv65j108_7m0000gn/T/python-build.20150127150918.87726/Python-3.4.1/Lib/ensurepip/__init__.py", line 40, in _run_pip
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

Solution: use the following statement to install to solve the problem

CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.4.1

reason:

zipimport.ZipImportError: can't decompress data; zlib not available

So far, the installation of the new version of Python is complete. You can use pyenv versions to view the installation results( The asterisk here should be on the system. I have modified the python version.)

 system
* 3.4.1 (set by /usr/local/var/pyenv/version)

In addition, warm reminder, after using homebrew to install pyenv, the prompt to install homebrew is in. Bash_ I don’t know if it has anything to do with the order. I can’t change the version of Python after adding it backwards.

You can use brew info pyenv to view these two sentences.
the results are as follows:

pyenv: stable 20160310, HEAD
Python version management
https://github.com/yyuu/pyenv
/usr/local/Cellar/pyenv/20160310 (473 files, 2.1M) *
  Built from source
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/pyenv.rb
==> Dependencies
Recommended: autoconf ✔, pkg-config ✔, openssl ✔, readline ✔
==> Options
--without-autoconf
    Build without autoconf support
--without-openssl
    Build without openssl support
--without-pkg-config
    Build without pkg-config support
--without-readline
    Build without readline support
--HEAD
    Install HEAD version
==> Caveats
To use Homebrew's directories rather than ~/.pyenv add to your profile:
  export PYENV_ROOT=/usr/local/var/pyenv

To enable shims and autocompletion add to your profile:
  if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi

That is to add the following two sentences:

To use Homebrew's directories rather than ~/.pyenv add to your profile:
  export PYENV_ROOT=/usr/local/var/pyenv

To enable shims and autocompletion add to your profile:
  if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi

At this point, you can successfully switch the python version by using pyenv global 3.4.1 .

Similar Posts: