0

Following an upgrade to MacOS Mojave I rebuilt my Python development environment using Homebrew and Pyenv.

  • I first updated XCODE and my SDK headers ( https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624 ).

    sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
    
  • Using homebrew I installed the Pyenv, Readline and XZ.

    $ brew update
    $ brew install pyenv readline xz
    
  • Then using Pyenv I installed the various Python packages:

    $ pyenv install 3.5.0
    $ pyenv install 2.7.10
    
  • The Pyenv installer advised me that it was using Homebrew's readline.

    Installing Python-3.5.0...
    python-build: use readline from homebrew
    
  • When I attempt to run a Python program I get the error:

    ImportError: dlopen(/Users/me/.pyenv/versions/3.5.0/lib/python3.5/lib-dynload/readline.cpython-35m-darwin.so, 
    2): Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib
    Referenced from: /Users/me/.pyenv/versions/3.5.0/lib/python3.5/lib-dynload/readline.cpython-35m-darwin.so
    Reason: image not found
    
  • Looking in /usr/local/opt/readline/lib all I see is version 8 libraries.

    $ ls /usr/local/opt/readline/lib
    libhistory.8.0.dylib    libhistory.a        libreadline.8.0.dylib   libreadline.a       pkgconfig
    libhistory.8.dylib  libhistory.dylib    libreadline.8.dylib libreadline.dylib
    

At this point I don't know if I should: A) figure out how to install readline v.7 via homebrew, or B) somehow update pyenv to not use homebrew's readline but install the library itself, or C) something else.

Any assistance will be greatly appreciated.

Chris Luther
  • 1
  • 1
  • 3

1 Answers1

0

This issue seems to be resolved in Python 3.7.2 if you're able to upgrade. I flailed with the same problem with both Python 3.6.7 and 3.7.1 and was never able to accomplish any sort of rollback to a readline v.7 with homebrew, which didn't seem to maintain any previous versions as taps for some reason.

AJ Donich
  • 31
  • 5