Problems installing python 3.6 with pyenv on Mac OS Big Sur

We Are Going To Discuss About Problems installing python 3.6 with pyenv on Mac OS Big Sur. So lets Start this Python Article.

Problems installing python 3.6 with pyenv on Mac OS Big Sur

  1. How to solve Problems installing python 3.6 with pyenv on Mac OS Big Sur

    Thanks to jordanm,
    The solution was to follow https://github.com/pyenv/pyenv/issues/1740#issuecomment-738749988
    brew reinstall zlib bzip2
    From people's comments (thanks to Lukasz Czerwinski and Alex Veksler) it seems many view this next step as optional (and even dangerous) and prefer to skip it; though, it's worth a try if nothing else is working:
    sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install
    Whether you chose to skip the last step or not, continue by editing .zshrc or .bashrc using:
    nano ~/.zshrc or nano ~/.bashrc
    and add:
    export PATH="$HOME/.pyenv/bin:$PATH" export PATH="/usr/local/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/bzip2/lib" export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/bzip2/include"
    after editing and saving that file, run:
    . ~/.zshrc or . ~/.bashrc
    Then run the command below to install (changing 3.6.0 for the desired patch)
    CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.6.0 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

  2. Problems installing python 3.6 with pyenv on Mac OS Big Sur

    Thanks to jordanm,
    The solution was to follow https://github.com/pyenv/pyenv/issues/1740#issuecomment-738749988
    brew reinstall zlib bzip2
    From people's comments (thanks to Lukasz Czerwinski and Alex Veksler) it seems many view this next step as optional (and even dangerous) and prefer to skip it; though, it's worth a try if nothing else is working:
    sudo rm -rf /Library/Developer/CommandLineTools xcode-select --install
    Whether you chose to skip the last step or not, continue by editing .zshrc or .bashrc using:
    nano ~/.zshrc or nano ~/.bashrc
    and add:
    export PATH="$HOME/.pyenv/bin:$PATH" export PATH="/usr/local/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/bzip2/lib" export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/bzip2/include"
    after editing and saving that file, run:
    . ~/.zshrc or . ~/.bashrc
    Then run the command below to install (changing 3.6.0 for the desired patch)
    CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.6.0 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

Solution 1

Thanks to jordanm,
The solution was to follow https://github.com/pyenv/pyenv/issues/1740#issuecomment-738749988

brew reinstall zlib bzip2

From people’s comments (thanks to Lukasz Czerwinski and Alex Veksler) it seems many view this next step as optional (and even dangerous) and prefer to skip it; though, it’s worth a try if nothing else is working:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install

Whether you chose to skip the last step or not, continue by editing .zshrc or .bashrc using:

nano ~/.zshrc or nano ~/.bashrc

and add:

export PATH="$HOME/.pyenv/bin:$PATH"
export PATH="/usr/local/bin:$PATH"

eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/bzip2/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/bzip2/include"

after editing and saving that file, run:

. ~/.zshrc or . ~/.bashrc

Then run the command below to install (changing 3.6.0 for the desired patch)

CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.6.0 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

Original Author edited Jul 19, 2021 at 16:25 Of This Content

Solution 2

According to this: https://github.com/pyenv/pyenv/issues/1737#issuecomment-731672292 this is related to a commit issue and the following fixes it. It worked for me.

CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" 

LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib"

pyenv install --patch 3.6.13 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

Original Author maede rayati Of This Content

Solution 3

The following steps finally worked for my MacBook Air M1 with Big Sur 11.6.

‼️ Please note that this instruction is for Rosetta 2 emulated x86 terminal.

  1. Install brew:

    arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  2. Install the recommended dependencies:

    arch -x86_64 brew install openssl readline sqlite3 xz zlib
    
  3. Install Pyenv with brew:

    arch -x86_64 brew install pyenv
    
  4. Configure your shell’s environment (in my case zsh):

    echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zshrc
    
  5. Restart the terminal.

  6. Add environment variables (in my case the problem was with zlib and openssl):

    export LDFLAGS="-L/usr/local/opt/zlib/lib"
    export CPPFLAGS="-I/usr/local/opt/zlib/include"
    export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
    export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
    
  7. Install the required Python version with patch:

    arch -x86_64 pyenv install --patch 3.6.15 <<(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
    
  8. Switch shell to new Python version:

    pyenv shell 3.6.15
    
  9. Check the currently used Python version:

    pyenv which python3
    

Original Author spyker77 Of This Content

Solution 4

The answer by Jacob Anderson was right, but it’s worth noting that there’s no need to perform the dangerous step:

sudo rm -rf /Library/Developer/CommandLineTools 

Things worked for me (installed Python 3.6.0 on MacOS 11.4) without doing it. Thanks to Jacob!

Original Author Alex Veksler Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment