[英]python exception <type 'exceptions.ImportError'> No module named gdb:
I've just compiled gdb 7.8
from source in my home directory on a server machine running linux.我刚刚在运行 linux 的服务器机器上的主目录中从源代码编译了
gdb 7.8
。 I had previously been using gdb 7.6
, and aside from stability issues with gdb
itself (the reason for the upgrade) everything worked fine.我以前一直在使用
gdb 7.6
,除了gdb
本身的稳定性问题(升级的原因)之外,一切正常。
Since the upgrade of gdb
, when I run cgdb 0.6.7
I immediately get the following message:自从
gdb
升级后,当我运行cgdb 0.6.7
我立即收到以下消息:
Python Exception <type 'exceptions.ImportError'> No module named gdb: warning: Could not load the Python gdb module from `/home/username/bin/gdb//python'. Limited Python support is available from the _gdb module. Suggest passing --data-directory=/path/to/gdb/data-directory.
When I built gdb
, I used ./configure --with-python
.当我构建
gdb
,我使用了./configure --with-python
。
When I run cgdb
and my program reaches a segfault, I type backtrace
and get the following message:当我运行
cgdb
并且我的程序遇到段cgdb
,我键入backtrace
并收到以下消息:
Python Exception No module named gdb.frames:
Python 异常没有名为 gdb.frames 的模块:
So it seems like I am effectively unable to use gdb
/ cgdb
without python support.因此,
cgdb
没有 python 支持,我似乎无法有效地使用gdb
/ cgdb
。 What can I do to resolve this?我能做些什么来解决这个问题?
FWIW; FWIW; I don't use
python
, I usually write c++
.我不使用
python
,我通常写c++
。
You should specify the value of " --data-directory
".您应该指定“
--data-directory
”的值。 For example, if you load gdb
from the build directory, the command should be:例如,如果从构建目录加载
gdb
,命令应该是:
./gdb -data-directory ./data-directory
Then gdb
can know where to find python
module.然后
gdb
可以知道在哪里可以找到python
模块。
You can refer this discussion .你可以参考这个讨论。
root@labs:~/gdb-8.1# gdb --version
Python Exception <type 'exceptions.ImportError'> No module named gdb:
gdb: warning:
Could not load the Python gdb module from `/usr/local/share/gdb/python'.
Limited Python support is available from the _gdb module.
Suggest passing --data-directory=/path/to/gdb/data-directory.
....
Try to cp python lib to --data-directory= /path/to/gdb/data-directory
.尝试 cp python lib 到 --data-directory=
/path/to/gdb/data-directory
。 My data directory is /usr/local/share/gdb/python ,我的数据目录是/usr/local/share/gdb/python ,
# mkdir -p /usr/local/share/gdb/python/gdb
# cp -rf ~/gdb-8.1/gdb/python/lib/gdb/* /usr/local/share/gdb/python/gdb/
# gdb --version
GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
I just ran into this and wanted to share what I found.我刚遇到这个,想分享我的发现。 During compilation, specifically the 'make install' step, I noticed this message:
在编译期间,特别是在“make install”步骤中,我注意到了这条消息:
WARNING: `makeinfo' is missing on your system. You should only need it if
you modified a `.texi' or `.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy `make' (AIX,
DU, IRIX). You might want to install the `Texinfo' package or
the `GNU make' package. Grab either from any GNU archive site.
It sounds as if it's OK that I don't have makeinfo
, but in fact it led to the error that the OP asked about.听起来好像我没有
makeinfo
没关系,但实际上它导致了OP询问的错误。 After installing texinfo
I then reran make install
and ran gdb
with no python error message.安装
texinfo
我重新运行make install
并运行gdb
,没有 python 错误消息。
just to complete the above responses:只是为了完成上述回复:
Probably you have copied the executable gdb to /usr/local/bin
(which is my way to prioritize the lastest gdb that I installed as default shell gdb , while preventing messing up with the default Ubuntu's gdb ).可能您已将可执行文件gdb复制到
/usr/local/bin
(这是我优先考虑安装为默认 shell gdb的最新 gdb 的方式,同时防止弄乱默认的 Ubuntu 的gdb )。 Then you should consider that you must give the data-directory parameter from the original place to the one that you have copied in /usr/local/bin
.那么你应该考虑你必须将 data-directory 参数从原始位置提供给你在
/usr/local/bin
复制的那个。 So that would be:所以那将是:
/usr/local/bin/gdb --data-directory=/path_to_fully_installed_gdb_folder/data-directory
PS: I did this for gdb-8.1 on Ubuntu 16.04 PS:我在Ubuntu 16.04上为gdb-8.1做了这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.