<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - lldb links with system Python library but runs Python from PATH"
   href="https://bugs.llvm.org/show_bug.cgi?id=38974">38974</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lldb links with system Python library but runs Python from PATH
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>lldb
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>lldb-dev@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>tdhutt@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>See <a href="https://stackoverflow.com/q/47658596/265521">https://stackoverflow.com/q/47658596/265521</a> especially the comments to this
answer: <a href="https://stackoverflow.com/a/47658597/265521">https://stackoverflow.com/a/47658597/265521</a>

Basically Python 2 on OSX is kind of a mess (like Python everywhere really).
OSX always comes with an installation of Python 2, but it is often an old
version, doesn't have pip, etc. For this reason a lot of people like to install
a copy of Python 2 from brew. Unfortunately that means you then have two copies
of Python 2.

LLVM always links with the system Python 2 framework, but when it runs the
Python 2 executable it finds it from PATH, which probably is the one from brew.
This causes an error:

    ImportError: cannot import name _remove_dead_weakref

A crappy workaround is to hack PATH when you run lldb, or to uninstall brew's
Python 2.

A proper solution is either:

1. Hard-code LLDB to always run `/usr/bin/python` on OSX since that's the one
it linked with.

2. Get LLDB to load the framework based on where Python says it is (e.g. from
`sysconfig.get_config_var("LIBDIR")` - see
<a href="https://stackoverflow.com/questions/47423246/get-pythons-lib-path">https://stackoverflow.com/questions/47423246/get-pythons-lib-path</a> )

I think the former solution is much easier and possibly more correct - you
probably don't want to link against one Python framework at compile time and
then run it with another at runtime. Maybe OSX can handle versioning properly
in that case though, I don't know.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>