Intel® Distribution for Python*
Engage in discussions with community peers related to Python* applications and core computational packages.
424 Discussions

vi-like key bindings in Intel python interactive command line interpreter

norio
Beginner
1,036 Views

How can I use the vi-like key bindings in the REPL (the interactive command line interpreter) of Intel Python?

 

I use Ubuntu Linux, and I have set up the system default python to accept the vi-like key bindings (e.g. `k` for previous line in the history) by writing the following line in `~/.inputrc`

 

```

set editing-mode vi

```

 

This configuration file is read by `readline` library, which is used by the system default python REPL. However, this file does not seem to be taking effect on Intel python.

 

I got Intel python as a part of OneAPI toolkit. I recently installed Intel fortran, C++, and DPC++ compilers from OneAPI toolkits via Ubuntu APT package manager, and Intel python seems to have been installed as a dependency. It is installed at `/opt/intel/oneapi/intelpython/latest/bin/python3` separately from the system default python, `/usr/bin/python3.8`.

 

Labels (1)
0 Kudos
1 Solution
JyothisV_Intel
Moderator
1,015 Views

Hi,

 

Good day to you.

 

Thanks for posting in Intel Communities.

 

To use vi-like key bindings in Intel Python, you need to install gnureadline package since Intel Python uses GPL code and that license is not compatible with the Intel MKL library.

 

To install gnureadline, just run the following command:

pip install gnureadline

Once, this is done, Intel Python will respect the ~/.inputrc file containing the "set editing-mode vi" line.

 

If this resolves your issue, make sure to accept this as a solution. This would help others with a similar issue. 

 

Thanks and Regards,

Jyothis V James

 

View solution in original post

0 Kudos
3 Replies
JyothisV_Intel
Moderator
1,016 Views

Hi,

 

Good day to you.

 

Thanks for posting in Intel Communities.

 

To use vi-like key bindings in Intel Python, you need to install gnureadline package since Intel Python uses GPL code and that license is not compatible with the Intel MKL library.

 

To install gnureadline, just run the following command:

pip install gnureadline

Once, this is done, Intel Python will respect the ~/.inputrc file containing the "set editing-mode vi" line.

 

If this resolves your issue, make sure to accept this as a solution. This would help others with a similar issue. 

 

Thanks and Regards,

Jyothis V James

 

0 Kudos
norio
Beginner
1,001 Views

Thank you for your answer. I installed gnureadline package by pip3, and it's working.

 

For those who may be viewing this thread later, I leave some comments.

 

I had two pip3. One from Ubuntu, and one from Intel. My PATH environmental variable was set up so that the pip3 command points to Ubuntu pip3 at `/usr/bin/pip3`. I re-arranged the set up, so that pip3 points to Intel pip3 at `/opt/intel/oneapi/intelpython/latest/bin/pip3` before running the pip3 install. (I think I could use the full path `/opt/intel/oneapi/intelpython/latest/bin/pip3 install gnureadline` without modifying PATH.)

 

I did the following command as a normal user,

 

```

pip3 install gnureadline

```

 

Then, the gnureadline package was installed to `~/.local/lib/python3.9/site-packages/`.

The system default pip3 uses `~/.local/lib/python3.8/site-packages/` because the system default python version is 3.8.

I wonder what happens if the Intel python and system python were the same version.

It may have been wise to do the pip3 command with sudo and installed the gnureadline package in

`/opt/intel/oneapi/intelpython/python3.9/lib/python3.9/site-packages/` (or somewhere).

This would be good for avoiding the collision and consistent to having already installed OneAPI tool kits by sudo.

 

JyothisV_Intel
Moderator
966 Views

Hi,


Good day to you.


Glad to know that your issue is resolved. Thanks for sharing that information with the community.



Kindly note the following:


System Python packages are typically stored to

/home/<username>/.local/lib/python3.x/site-packages/


Intel Python packages if Intel oneAPI Basekit is installed without sudo privillege are stored to

/home/<username>/intel/oneapi/intelpython/latest/lib/python3.y/site-packages/


Intel Python packages if Intel oneAPI Basekit is installed with sudo privillege are stored to

/opt/intel/oneapi/intelpython/latest/lib/python3.y/site-packages/



Hope this clears your doubts. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.


Thanks and Regards,

Jyothis V James


0 Kudos
Reply