Can't use help function in interative mode

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Rich Lion
Posts: 4
Joined: Wed Jun 09, 2021 3:11 pm

Can't use help function in interative mode

Post by Rich Lion » Wed Jun 09, 2021 3:24 pm

[*][*][*]Hi, Team

I am new to micropython. I download the latest code and build for unix port following the instructiong in github readme. But found that I can't use help(module_name) in the micropython interactive mode. Could anyone give a hint. Thanks.

Build and Test Host: Ubuntu 18.04
Test Steps:
```
$ git clone https://github.com/micropython/micropython.git
$ cd ports/unix
$ make submodules
$ make
$ ./micropython
MicroPython v1.15 on 2021-04-20; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import sys
>>> help(sys)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'help' isn't defined
```
I can also find below files avaiable:
./ports/unix/build-standard/py/builtinhelp.o
./ports/unix/build-standard/py/builtinhelp.P

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Can't use help function in interative mode

Post by Roberthh » Wed Jun 09, 2021 3:59 pm

Modules help is not enabled in the Linux port by default. You could try adding the line:

#define MICROPY_PY_BUILTINS_HELP_MODULES (1)

to mpconfigport.h. It is usually located next to the other #defines related to help.

Rich Lion
Posts: 4
Joined: Wed Jun 09, 2021 3:11 pm

Re: Can't use help function in interative mode

Post by Rich Lion » Thu Jun 10, 2021 12:46 am

Thanks for your reply.
I add the line as you said and do "make clean; make". But help module still can't work.
```
diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h
index d838f42b3..f177f67a6 100644
--- a/ports/unix/mpconfigport.h
+++ b/ports/unix/mpconfigport.h
@@ -66,6 +66,7 @@
#define MICROPY_READER_POSIX (1)
#define MICROPY_USE_READLINE_HISTORY (1)
#define MICROPY_HELPER_REPL (1)
+#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
#define MICROPY_REPL_EMACS_KEYS (1)
#define MICROPY_REPL_AUTO_INDENT (1)
#define MICROPY_HELPER_LEXER_UNIX (1)
```



Roberthh wrote:
Wed Jun 09, 2021 3:59 pm
Modules help is not enabled in the Linux port by default. You could try adding the line:

#define MICROPY_PY_BUILTINS_HELP_MODULES (1)

to mpconfigport.h. It is usually located next to the other #defines related to help.

Post Reply