saghul / pythonz

Python installation manager supporting CPython, Stackless, PyPy and Jython
http://saghul.github.io/pythonz
MIT License
751 stars 69 forks source link

Failed to install python 3.6.10 but it worked for python 3.7.6 #156

Closed thoongnv closed 4 years ago

thoongnv commented 4 years ago

I got an issue with zlib when install 3.6.10 with this command: sudo-pythonz install 3.6.10 (also failed with 3.6.8, 3.6.9)

Traceback (most recent call last):
  File "/Users/thoong/.pythonz/build/CPython-3.6.10/Lib/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/thoong/.pythonz/build/CPython-3.6.10/Lib/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/thoong/.pythonz/build/CPython-3.6.10/Lib/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/Users/thoong/.pythonz/build/CPython-3.6.10/Lib/ensurepip/__init__.py", line 204, in _main
    default_pip=args.default_pip,
  File "/Users/thoong/.pythonz/build/CPython-3.6.10/Lib/ensurepip/__init__.py", line 117, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/Users/thoong/.pythonz/build/CPython-3.6.10/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip._internal
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] Error 1

But it worked with sudo-pythonz install 3.7.10

So I think zlib is not a issue, because I already config in .zshrc

# zlib
export LDFLAGS="${LDFLAGS} -L/usr/local/opt/zlib/lib"
export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/zlib/include"
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/local/opt/zlib/lib/pkgconfig"
ifduyue commented 4 years ago

It seemed that sudo-pythonz didn't preserve those env vars

thoongnv commented 4 years ago

It seems work now, here is my config I put in ~/.zshrc

# openssl
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

# zlib
export LDFLAGS="${LDFLAGS} -L/usr/local/opt/zlib/lib"
export CPPFLAGS="${CPPFLAGS} -I/usr/local/opt/zlib/include"
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH} /usr/local/opt/zlib/lib/pkgconfig"

export CPATH=`xcrun --show-sdk-path`/usr/include