9 LLDB has a powerful scripting interface which is accessible through Python.
10 Python is available either from within LLDB through a (interactive) script
11 interpreter, or as a Python module which you can import from the Python
14 To make this possible, LLDB links against the Python shared library. Linking
15 against Python comes with some constraints to be aware of.
17 1. It is not possible to build and link LLDB against a Python 3 library and
18 use it from Python 2 and vice versa.
20 2. It is not possible to build and link LLDB against one distribution on
21 Python and use it through an interpreter coming from another distribution.
22 For example, on macOS, if you build and link against Python from
23 python.org, you cannot import the lldb module from the Python interpreter
24 installed with Homebrew.
26 3. To use third party Python packages from inside LLDB, you need to install
27 them using a utility (such as ``pip``) from the same Python distribution as
28 the one used to build and link LLDB.
30 The previous considerations are especially important during development, but
31 apply to binary distributions of LLDB as well.
33 LLDB in Xcode on macOS
34 ``````````````````````
36 Users of lldb in Xcode on macOS commonly run into these issues when they
37 install Python, often unknowingly as a dependency pulled in by Homebrew or
38 other package managers. The problem is the symlinks that get created in
39 ``/usr/local/bin``, which comes before ``/usr/bin`` in your path. You can use
40 ``which python3`` to check to what it resolves.
42 To be sure you use the Python that matches with the lldb in Xcode use ``xcrun``
43 or use the absolute path to the shims in ``/usr/bin``.
50 Similarly, to install packages and be able to use them from within lldb, you'll
51 need to install them with the matching ``pip3``.
58 The same is true for Python 2. Although Python 2 comes with the operating
59 system rather than Xcode, you can still use ``xcrun`` to launch the system
67 Keep in mind that Python 2 is deprecated and no longer maintained. Future
68 versions of macOS will not include Python 2.7.