1

I have python3 installed on a work computer.

Python 3.4.3 (default, May  3 2016, 09:46:33) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.

The interactive editor is not working. I can't use emacs control sequences, for example. I just get "^A" displayed instead of going to the beginning of my line.

There's mention of the feature here:

https://docs.python.org/3.4/tutorial/interactive.html

It says:

Some versions of the Python interpreter support editing of the 
current input line and history substitution, similar to facilities 
found in the Korn shell and the GNU Bash shell. This is implemented 
using the GNU Readline library, which supports various styles of 
editing. 

The docs don't say anything about needing to enable this feature, which versions of the Python interpreter support editing, or if there is perhaps something in the build process, assuming Python3 was built from source, that made the GNU Readline library not work. And, I've googled a bunch to see how I might fix the problem with no luck.

The odd thing is that there is Python 2 installed on the same machine and it supports interactive editing just fine. And, the Python 3 installed on my home machine works just fine too.

3
  • 3
    What distro is the work computer running? Where did the Python 3 installation come from? Was it from an official repository or compiled from source? My thoughts is that the version at work wasn't compiled with the readline library. May 3, 2016 at 18:51
  • I believe there was a compile problem. I didn't realize until I went to the Python install page that you have to build from source on Linux but that Mac is an exception in having prebuilt code.
    – Sol
    May 4, 2016 at 0:25
  • On GNU/Linux, install it from the distro's repo.
    – McSinyx
    May 4, 2016 at 3:28

1 Answer 1

1

I was the tech working on the issue and found how to get interactive editing to work. The issue with going through yum is since the OS using so much python we can’t update it through yum (company policy).

I had to compile python 3.4.3 from source. After it was compiled and installed, I had to add each package that was missing. This particular package was gnureadline. Readline is deprecated. Here are the steps I took to build and install the package (for CentOS 6.7):

  1. wget https://pypi.python.org/pypi/gnureadline/6.3.3
  2. tar -xzvf gnureadline-6.3.3.tar.gz
  3. cd gnureadline-6.3.3
  4. python3 setup.py install

    NOTE: Here I ran into an issue /usr/bin/ld: cannot find –lncurses. Using /usr/bin/ld –lncurses --verbose found that the paths it was searching didn’t have the libraries. Created a symlink and it worked. If you don't get the errors then skip to the last step.

  5. ln -s /lib64/libncurses.so.5.7 /usr/lib64/libncurses.so

  6. python3 setup.py install
  7. Verified I can use ctrl-a and arrow keys to move around in the line.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .