Skip to content

Instantly share code, notes, and snippets.

@potench
Last active February 9, 2021 22:03
Show Gist options
  • Save potench/c024f4499ba2f778d351d7d468daa842 to your computer and use it in GitHub Desktop.
Save potench/c024f4499ba2f778d351d7d468daa842 to your computer and use it in GitHub Desktop.
AVN, N, NVM, Pyenv VirtualEnv, Python Setup with macOS 11.1 Big Sur

Setup tips for AVN on Big Sur / macOS 11.1

I found installing AVN, NVM difficult on Big Sur OS 11.1. Here's the steps I took to fix:

  1. Install Homebrew

  2. Assume you're using zsh. If not, switch to zsh

  3. Install nvm

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
    1. Make sure the following is added to your ~/.zshrc file

      export NVM_DIR="$HOME/.nvm"
      [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    2. Make sure it works:

      exec "$SHELL" # reloads .zshrc, alternatively, restart yout terminal
      nvm --version # should output 0.37.2 or whatever
  4. Switch to Node 12 temporarily to finish installation of AVN. For some reason, avn setup fails with Node 14 =(

    nvm install 14.15.0 # you'll need this later
    nvm install 12.13.0
    nvm use 12.13.0
    node -v # should output 12.13.0
  5. Install AVN

    npm install -g avn avn-nvm avn-n
    avn setup
    1. Make sure the following is added to your ~.zshrc file

      [[ -s "$HOME/.avn/bin/avn.sh" ]] && source "$HOME/.avn/bin/avn.sh" # load avn
    2. Make sure it works:

      exec "$SHELL" # reloads .zshrc, alternatively, restart yout terminal
      mkdir ./test-avn
      echo "14.15.0" | tee ./test-avn/.nvmrc
      cd ./test-avn
      # expect to see Node 14.15.0 activated by AVN using .nvmrc
# change python version as needed
python_bin = $(wildcard ~/.pyenv/versions/3.6.9/bin/python3.6)
shell_src = $(shell echo *.sh)
.PHONY: shellcheck
shellcheck: ve
echo $(shell_src) | xargs shellcheck -x
.PHONY: ve
ve:
virtualenv --python=$(python_bin) .ve
. .ve/bin/activate && python -m pip install --upgrade pip && pip install -r requirements.txt
.PHONY: run
run: ve
# FLASK_APP env variable to auto reload
. .ve/bin/activate && IS_TEST=1 IS_DEV=1 FLASK_APP=application.py python3 application.py

Setup tips for Python on Big Sur / macOS 11.1

  1. Install Homebrew

  2. If you're using mysql, zlib, bzip2...

    brew install bzip2 lbzip2 lzlib zlib
    ## use `brew doctor` if you run into issues
    ## add to .zshrc
    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"
    
    brew install mysql     
    brew upgrade openssl
    ## add to .zshrc
    export CPPFLAGS=-I/usr/local/opt/openssl/include
    export LDFLAGS=-L/usr/local/opt/openssl/lib
  3. Install pyenv

    brew update
    brew install pyenv
    echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc # add pyenv to path
  4. To Setup Python < 3.8.x

    LDFLAGS="-L/usr/local/opt/bzip2/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/[email protected]/lib" CFLAGS="-I/usr/local/opt/bzip2/include -I/usr/local/opt/zlib/include -I/usr/local/opt/[email protected]/include -I$(xcrun --show-sdk-path)/usr/include -Wno-implicit-function-declaration" pyenv install 3.6.9
    
    
  5. To Setup Python > 3.8x+

    pyenv virtualenv 3.8.7 my-project
    pyenv activate my-project
    
  6. Upgrade pip locally If you are having issues with a specific requirement, you should try this step before installing requirements.

    python -m pip install --upgrade pip # upgrade pip locally
    
  7. Unpin any packages in requirements.txt that are causing you problems by removing vesion for the following that likely cause issues:

    grpcio # 1.35+
    grpcio-tools # 1.35+
    pandas
    urllib3
    
  8. Try installation again

    pip install -r requirements.txt
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment