zlib not available error with Python 2.7.18 and macos

I have a pipeline with actions/setup-python and macos-latest as runner. The pipeline works well, I got an artifact but when I run it, the following error is raised:

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

I have tried with setup-python versions v1/v2 and I got the same problem. Using a pyenv installation instead and installing zlib with brew, the artifact work as is expected.
Any suggestion? Thx

Would you mind sharing your workflow yml file and an example repo to reproduce this issue ? 

@yanjingzhu sure, here is an example:

run-package-macos:
   name: test
   runs-on: macOS-latest

   steps:
    - name: Checkout
      uses: actions/checkout@master
    - name: Set up Python 2.7
      uses: actions/setup-python@v1
      with:
        python-version: 2.7
    - name: install custom lib
      run: |
      	cd lib
    	pip install -r requirements.txt
        python setup.py install
        ...
    - name: build
      run: |
        ...
        python setup.py clean build
    ...

When I run the generated build, I got the zlib error. Same issue with python 3…8.  Using this following wa it works well:

- name: install python with zlib wa
  run: |
        brew update
        brew install zlib
        export CFLAGS="-I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include"
        export LDFLAGS="-L$(brew --prefix openssl)/lib"
        brew install pyenv
        pyenv install 2.7
        pyenv global 2.7

Thxs a lot! :slight_smile:

Hi @fgriberi

Setup python action will not install zlib . So you need to install zlib in another step and export some environment variables. The solution you found is great. It is the same as what’s tarrex said here:

https://github.com/pyenv/pyenv/issues/1219#issuecomment-448658430

1 Like