KCQs
KCQs

Reputation: 106

Pyenv on Mac Ventura: Python curses extension was not compiled

I'm trying to use pyenv to install python 3.11 (pyenv seems like a great tool for managing multiple python versions on per-project basis).

I am running on intel Ventura 13.3. Any help would be greatly appreciated.

When running

pyenv install 3.11

I get the error:

ModuleNotFoundError: No module named '_curses' WARNING: The Python curses extension was not compiled. Missing the ncurses lib?

What I've tried

Using ncurses installed via brew:

brew install ncurses
export CPPFLAGS="-I$(brew --prefix ncurses)/include"
export LDFLAGS="-L/usr/local/opt/ncurses/lib"
export PKG_CONFIG_PATH="/usr/local/opt/ncurses/lib/pkgconfig"
pyenv install 3.11

Linking brew libraries manually:

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

export LDFLAGS="-L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib -L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix ncurses)/lib -L$(xcrun --show-sdk-path)/usr/lib"

pyenv install 3.11

I've also reinstalled xcode-select and tried the above steps. What's more confusing to me is that I can see ncurses.h in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include.

How I installed pyenv

I installed pyenv via homebrew

brew update
brew install pyenv

then setup paths in my zshrc and zprofile

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

then installed python build dependencies

brew install openssl readline sqlite3 xz zlib tcl-tk

Upvotes: 3

Views: 1797

Answers (2)

mountrix
mountrix

Reputation: 1243

This helped me:

  1. Remove pyenv by rm -rf $HOME/.pyenv
  2. Re-install pyenv: https://akrabat.com/creating-virtual-environments-with-pyenv/ (especially the sudo apt-get install line)
  3. pyenv install <version>

Upvotes: 0

repleeka
repleeka

Reputation: 610

Python version 3.11 is relatively new in the market, so some packages and libraries my not fully support python3.11. You may encounter compatibility issues, so be sure to check the documentation or go through online community chats.

You may try the following few steps:

  • brew upgrade pyenv
  • brew install openssl readline sqlite3 xz zlib (install dependencies required for py3.11)
  • $ pyenv install 3.11.0
  • $ pyenv global 3.11.0 (set py3.11 global)

You may also want to verify if the py3.11 is installed or not by doing,

  • python --version

If you still encounters error then check if the python 3.11 is available for pyenv or not (since it is relatively new) by running the following script:

  • pyenv install -l (this will give the list of all available versions)

For more visit here

Upvotes: 0

Related Questions