在PYTHON中使用LLDB.PY模块,lldb.py文件在哪?

请教一下:
在lldb中,使用python时,会有:
import lldb
这个lldb怎么引入?
根据官方的文档:http://lldb.llvm.org/python-reference.html
USING THE LLDB.PY MODULE IN PYTHON
LLDB has all of its core code build into a shared library which gets used by the lldb command line application. On Mac OS X this shared library is a framework: LLDB.framework and on other unix variants the program is a shared library: lldb.so. LLDB also provides an lldb.py module that contains the bindings from LLDB into Python. To use the LLDB.framework to create your own stand-alone python programs, you will need to tell python where to look in order to find this module. This is done by setting the PYTHONPATH environment variable, adding a path to the directory that contains the lldb.py python module. On Mac OS X, this is contained inside the LLDB.framework, so you would do:

For sh and bash:
% export PYTHONPATH=/Developer/Library/PrivateFrameworks/LLDB.framework/Resources/Python

我的路径为:/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python
可是并没有lldb.py这个文件,这个文件在哪里??

问题解决,解决方法贴一下,希望对遇到同样困惑的同学有帮助。

想要在lldb使用python,用Pycharm工具写脚本的时候,
import lldb
发现没有这个lldb的模块,根据官方文档设置了PYTHONPATH路径,发现还是不行。
这个路径也没有lldb.py这样的文件。
有文件__init__.py,代码里有lldb的定义,看了下应该就是这个文件。
将文件改名,放到项目中,发现可以找到lldb模块了。
56

在敲代码时,可以自动补全了。

init.py应该是这个lldb文件夹的,规范的做法应该是把__init__.py文件所在的文件夹名字改成lldb就可以了,而不是改__init__.py的文件名

2 个赞

谢谢解惑。
试了一下,将lldb文件夹拷到site-packages中,import时,可以找到lldb模块。
应该这种是更规范的做法。

这是python packge.应该把python的搜索路径指向这里

python的路径试着配过,只是始终不起作用。只能用这个歪招了