Python 3.5+ Arrow keys and others in the console

Vincent Vande Vyvre vincent.vande.vyvre at telenet.be
Sun Apr 16 10:49:17 EDT 2017


Le 16/04/17 à 15:19, Wolfgang Maier a écrit :
> On 16.04.2017 10:56, Vincent Vande Vyvre wrote:
>> Hi,
>>
>> I'm using Python 3.5 and 3.6 in venv and I see a strange behaviour in
>> the interactive interpreter.
>>
>> The arrow keys can't be used to move the cursor into the current line of
>> code or to rewrite the last lines.
>>
>> With the 3.5 I can use the backspace and erase the code but not in 3.6
>>
>> Python 3.5.2 (default, Dec 19 2016, 11:46:33)
>> [GCC 4.8.4] on linux
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> f = "kjhfgt"^[[D            # Left Arrow Key
>>>>> ^[[A                        # Up Arrow Key
>>
>>
>> Python 3.6.1 (default, Apr 12 2017, 11:39:17)
>> [GCC 4.8.4] on linux
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>> f = "lkjgh"
>>>>> ^[[A^[[B                    # Up Arrow Key and Backspace Key
>>   File "<stdin>", line 1
>>
>>     ^
>> SyntaxError: invalid syntax
>>>>>
>>
>
> Make sure you build Python (I guess you did this for 3.6, but are 
> probably using your OS Python3.5) with readline. This needs the dev 
> version of the readline library installed at build time.
> So, step 1 would be to get the library, then rebuild Python3.6 by 
> running:
>
> 1) make clean
> 2) ./configure
> 3) make
>
> It could be worthwhile checking for other missing optional C libraries 
> first though. If you want to make sure you have all of them, follow 
> the steps described here:
>
> https://docs.python.org/devguide/setup.html#build-dependencies
>
> Best,
> Wolfgang
>
>

No, both are in venv, my system version is the 3.4.

Anyway, after "apt-get build-dep python3.4" and following your advice 
all works as expected.

Thanks Wolfgang.


Incidentally, with the 3.6 I've added the argument 
"--enable-optimizations" to the configure.

The unitest were executed and fail with hashlib, then it rerun some 
compilation, rerun the unittest, refail with hashlib, recompile some 
modules and finish without error. (see a little part of the log below)

I don't know if this is relevant ...


Vincent


----------------------------------------

0:06:47 [161/405] test_hash
0:06:49 [162/405] test_hashlib
Fatal Python error: Segmentation fault

Current thread 0x00002af5c0cfa380 (most recent call first):
   File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/support/__init__.py", line 
1508 in gc_collect
   File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/save_env.py", 
line 271 in __exit__
   File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/runtest.py", 
line 168 in runtest_inner
   File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/runtest.py", 
line 129 in runtest
   File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/main.py", line 
343 in run_tests_sequential
   File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/main.py", line 
418 in run_tests
   File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/main.py", line 
490 in _main
   File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/main.py", line 
468 in main
   File 
"/home/vincent/CPython/Python-3.6.1/Lib/test/libregrtest/main.py", line 
532 in main
   File "/home/vincent/CPython/Python-3.6.1/Lib/test/regrtest.py", line 
46 in _main
   File "/home/vincent/CPython/Python-3.6.1/Lib/test/regrtest.py", line 
50 in <module>
   File "/home/vincent/CPython/Python-3.6.1/Lib/runpy.py", line 85 in 
_run_code
   File "/home/vincent/CPython/Python-3.6.1/Lib/runpy.py", line 193 in 
_run_module_as_main
Segmentation fault (core dumped)
make[1]: quittant le répertoire « /home/vincent/CPython/Python-3.6.1 »
make build_all_merge_profile
make[1]: entrant dans le répertoire « /home/vincent/CPython/Python-3.6.1 »
true
make[1]: quittant le répertoire « /home/vincent/CPython/Python-3.6.1 »
Rebuilding with profile guided optimizations:
make clean
make[1]: entrant dans le répertoire « /home/vincent/CPython/Python-3.6.1 »
find . -depth -name '__pycache__' -exec rm -rf {} ';'
find . -name '*.py[co]' -exec rm -f {} ';'
find . -name '*.[oa]' -exec rm -f {} ';'
find . -name '*.s[ol]' -exec rm -f {} ';'
find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
find build -name 'fficonfig.h' -exec rm -f {} ';' || true
find build -name '*.py' -exec rm -f {} ';' || true
find build -name '*.py[co]' -exec rm -f {} ';' || true
rm -f pybuilddir.txt
rm -f Lib/lib2to3/*Grammar*.pickle
rm -f Programs/_testembed Programs/_freeze_importlib
find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
rm -f Include/pydtrace_probes.h
make[1]: quittant le répertoire « /home/vincent/CPython/Python-3.6.1 »
make build_all_use_profile
make[1]: entrant dans le répertoire « /home/vincent/CPython/Python-3.6.1 »
make build_all CFLAGS_NODIST=" -fprofile-use -fprofile-correction " 
LDFLAGS=" "
make[2]: entrant dans le répertoire « /home/vincent/CPython/Python-3.6.1 »
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv 
-O3 -Wall -Wstrict-prototypes    -std=c99 -Wextra -Wno-unused-result 
-Wno-unused-parameter -Wno-missing-field-initializers -fprofile-use 
-fprofile-correction   -I. -I./Include    -DPy_BUILD_CORE -o 
Programs/python.o ./Programs/python.c

....

-------------------------------------------------------



More information about the Python-list mailing list