python exception <type 'exceptions.ImportError'> No module named gdb:
python catch all exceptions
python exception with_traceback
python throw exception and exit
else block in python exception
python raise valueerror
python try except continue
python try except example
I've just compiled
gdb 7.8 from source in my home directory on a server machine running linux. I had previously been using
gdb 7.6, and aside from stability issues with
gdb itself (the reason for the upgrade) everything worked fine.
Since the upgrade of
gdb, when I run
cgdb 0.6.7 I immediately get the following message:
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
When I run
cgdb and my program reaches a segfault, I type
backtrace and get the following message:
Python Exception No module named gdb.frames:
So it seems like I am effectively unable to use
cgdb without python support. What can I do to resolve this?
FWIW; I don't use
python, I usually write
You should specify the value of "
--data-directory". For example, if you load
gdb from the build directory, the command should be:
./gdb -data-directory ./data-directory
gdb can know where to find
You can refer this discussion.
Built-in Exceptions, In Python, all exceptions must be instances of a class that derives from BaseException . In a try statement with an except clause that mentions a particular class, An exception can be a string, a class or an object. Most of the exceptions that the Python core raises are classes, with an argument that is an instance of the class. Note: In order to catch an exception, an "except" clause must refer to the same exception thrown either class object or simple string.
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. My data directory is /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".
8. Errors and Exceptions, File name and line number are printed so you know where to look in case the input came from a script. 8.2. Exceptions¶. Even if a statement or expression is In Python, all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that mentions a particular class, that clause also handles any exception classes derived from that class (but not exception classes from which it is derived).
I just ran into this and wanted to share what i found. During compilation, specifically the 'make install' step, i noticed a messages saying this:
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. When I installed
texinfo I then reinstalled
make install and ran gdb with no python error message.
Handling Exceptions - Python Wiki, The simplest way to handle exceptions is with a "try-except" block: In the first example above, if you were using a catch-all exception clause The try and except Block: Handling Exceptions. The try and except block in Python is used to catch and handle exceptions. Python executes code following the try statement as a “normal” part of the program. The code that follows the except statement is the program’s response to any exceptions in the preceding try clause.
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). 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. So that would be:
PS: I did this for gdb-8.1 on Ubuntu 16.04
Python Exceptions: An Introduction – Real Python, In Python, exceptions can be handled using a try statement. A critical operation which can raise an exception is placed inside the try clause and the code that An exception can be a string, a class or an object. Most of the exceptions that the Python core raises are classes, with an argument that is an instance of the class. Note − In order to catch an exception, an "except" clause must refer to the same exception thrown either as a class object or a simple string.
Python Exception Handling - Try, Except and Finally, Exception Handling. When an error occurs, or exception as we call it, Python will normally stop and generate an error message. These exceptions can be handled Exception Handling¶. The functions described in this chapter will let you handle and raise Python exceptions. It is important to understand some of the basics of Python exception handling.
Python Try Except, An exception is an event, which occurs during the execution of a program that disrupts the normal flow of the program's instructions. In general, when a Python Python Exception Handling - Try, Except and Finally In this article, you'll learn how to handle exceptions in your Python program using try, except and finally statements. This will motivate you to write clean, readable and efficient code in Python.
Python - Exceptions Handling, Overview In this post we will cover how Python handles errors with exceptions. What is an Exception? An exception is In the case of Python, calling a function that may raise an exception is no more difficult or unsafe than calling a function that returns a status flag and a result, but writing the function itself is much easier, with fewer places for the programmer to make a mistake.
- I don't have a
data-directoryin the folder where the
gdbbinary is, so doing this results in the same error.
- @Arman: I think you should specify the
-data-directoryvalue as the build folder for gdb.
- If you no longer have the source tree with
data-directoryin it, you can try
/path/to/your/gdb --data-directory=/usr/share/gdb(or wherever your distro puts it).
- Even more useful : what config file can I put this path in, so I can forget about this problem?
- If you build GDB from source then the data-directory is copied to the build/gdb folder.