Home iOS & Swift Books Advanced Apple Debugging & Reverse Engineering

B
Appendix B: Python Environment Setup Written by Derek Selander

Heads up... You're reading this book for free, with parts of this chapter shown beyond this point as scrambled text.

You can unlock the rest of this book, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.

It’s not my place to force an IDE on you for Python development. However, if you’re actively looking for a Python editor for the Python related chapters — then we should have a little chat.

Getting Python

Good news: if you have a Mac, it automatically ships (at the time of writing) with Python version 2.7. This is the same version LLDB uses.

If, for some weird reason, you like to rm random things in Terminal and you need to reinstall Python, you can download Python here: https://www.python.org/downloads/. Make sure to download the version of Python that matches the version packaged with LLDB. If you’re not sure which version to get, you can get the LLDB Python version through Terminal:

lldb
(lldb) script import sys; print sys.version

Don’t worry about the final part of the version number. If you have 2.7.12 and LLDB quotes 2.7.10, that will work just fine.

Python text editors

A list of Python editors can be found here: https://wiki.python.org/moin/PythonEditors.

Working with the LLDB Python module

When working with Python, you’ll often import modules to execute code or classes within that module. When working with LLDB’s Python module, you’ll sometimes come across an import lldb somewhere in the script, usually right at the top.

touch ~/.bash_profile
export PYTHONPATH=/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/Python:$PYTHONPATH

Have a technical question? Want to report a bug? You can ask questions and report bugs to the book authors in our official book forum here.

Have feedback to share about the online reading experience? If you have feedback about the UI, UX, highlighting, or other features of our online readers, you can send them to the design team with the form below:

© 2021 Razeware LLC

You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.

Unlock Now

To highlight or take notes, you’ll need to own this book in a subscription or purchased by itself.