lukejanicke lukejanicke - 2 months ago 73
Python Question

Building Python 3 on OS X: [Python/importlib.h] Error 133

I am trying to build Python (3.5.2) on OS X El Capitan (10.11.5). However, I run into an error when I try to

make
it. The error seems to be related to
_freeze_importlib
.

/usr/local/src/Python-3.5.2 $ make
if test "no" != "yes"; then \
./Programs/_freeze_importlib \
./Lib/importlib/_bootstrap.py Python/importlib.h; \
fi
dyld: lazy symbol binding failed: Symbol not found: _getentropy
Referenced from: /usr/local/src/Python-3.5.2/./Programs/_freeze_importlib
Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _getentropy
Referenced from: /usr/local/src/Python-3.5.2/./Programs/_freeze_importlib
Expected in: /usr/lib/libSystem.B.dylib

/bin/sh: line 1: 56666 Trace/BPT trap: 5 ./Programs/_freeze_importlib ./Lib/importlib/_bootstrap.py Python/importlib.h
make: *** [Python/importlib.h] Error 133
/usr/local/src/Python-3.5.2 $


You can see my steps on GitHub.

The full Terminal output up to the
make
fail is in a Gist.




I fully acknowledge that this is an academic exercise, as El Capitan comes with Python 2.7.10 and you can easily install Python 3.5.2 with the official OS X installer package or via Homebrew.

The documentation for Using Python on Unix platforms provides build instructions. The documentation for Using Python on a Macintosh specifically says to use the the OS X installer package.

However, it should be possible to build on Mac.


Python on a Macintosh running Mac OS X is in principle very similar to Python on any other Unix platform, but there are a number of additional features such as the IDE and the Package Manager that are worth pointing out.


At this point, I'm not worried about those additional features. Just curious about why I am getting a
make
error.

Answer

Fixed.

In the output of ./configure, I noticed a reference to /Applications/Xcode-beta.app/Contents/Developer/. I installed Xcode 8 (beta) a few days ago. After switching back to the regular Command Line Tools (with Xcode 7.3.1)

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

make succeeded. Not perfectly.

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_dbm                  _gdbm                 _sqlite3           
_ssl                  nis                   ossaudiodev        
spwd                  zlib                                     
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Failed to build these modules:
_lzma                 _tkinter 

I hope I don't need those modules.

I've put the full output of ./configure and make in this Gist. I didn't include the output for make install as it was too long and seemed to only repeat the warnings and errors of make.

Notes

  • I didn't use --enable-framework or --enable-universalsdk.