質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

0回答

374閲覧

Python3でCtrl+Lで画面をクリアしたい

teityura

総合スコア84

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2019/07/08 06:35

前提・実現したいこと

Python3でCtrl+Lで画面をクリアしたい

発生している問題・エラーメッセージ

現状、Ctrl+L入力で、前の行をコピーするような動きになる。

>>> a = 3 # Ctrl+L 押下 >>> a = 3 # Ctrl+L 押下 >>> a = 3 # Ctrl+L 押下 >>> a = 3 # Ctrl+L 押下

試したこと

gnureadlineを入れてみました。
pip install gnureadline
入れて、Ctrl+方向キーが[[A[[B[[C[[Dになっていた問題が解決したが、
Ctrl+Lが思った動きをしてくれない。

補足情報(FW/ツールのバージョンなど)

os.system('clear')は動く

>>> import os >>> os.system('clear') # 実行後、画面が更新され、先頭行が0になる 0 >>>

libreadline-devは入っていた。

apt show libreadline-dev Package: libreadline-dev Version: 6.3-8ubuntu2 Priority: optional Section: libdevel Source: readline6 Origin: Ubuntu

readlineのインストールに失敗する

(sqlalchemy-tutorial) cloud@dev-ubu ~/w/p/sqlalchemy-tutorial> pip install readline Collecting readline Using cached https://files.pythonhosted.org/packages/f4/01/2cf081af8d880b44939a5f1b446551a7f8d59eae414277fd0c303757ff1b/readline-6.2.4.1.tar.gz Installing collected packages: readline Running setup.py install for readline ... error Complete output from command /home/cloud/work/python3.6.0/sqlalchemy-tutorial/bin/python3.6.0 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-a0t6v7b1/readline/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-9mlhc520-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/cloud/work/python3.6.0/sqlalchemy-tutorial/include/site/python3.6/readline: ============ Building the readline library ============ readline-6.2/ readline-6.2/doc/ readline-6.2/doc/Makefile.in readline-6.2/doc/texinfo.tex readline-6.2/doc/version.texi readline-6.2/doc/fdl.texi (略) patching file support/shobj-conf patching file patchlevel patching file input.c patching file patchlevel patching file vi_mode.c patching file patchlevel checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu Beginning configuration for readline-6.2 for x86_64-unknown-linux-gnu checking whether make sets $(MAKE)... yes checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for ANSI C header files... yes (略) configure: creating ./config.status config.status: creating Makefile config.status: creating doc/Makefile config.status: creating examples/Makefile config.status: creating shlib/Makefile config.status: creating config.h config.status: executing default commands rm -f readline.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O readline.c rm -f vi_mode.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O vi_mode.c rm -f funmap.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O funmap.c rm -f keymaps.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O keymaps.c rm -f parens.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O parens.c rm -f search.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O search.c search.c: In function ‘_rl_nsearch_init’: search.c:213:15: warning: too many arguments for format [-Wformat-extra-args] rl_message ("%s", p, 0); ^ rm -f rltty.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O rltty.c rm -f complete.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O complete.c complete.c: In function ‘fnwidth’: complete.c:682:12: warning: implicit declaration of function ‘wcwidth’ [-Wimplicit-function-declaration] w = wcwidth (wc); ^ rm -f bind.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O bind.c rm -f isearch.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O isearch.c rm -f display.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O display.c display.c: In function ‘rl_redisplay’: display.c:764:15: warning: implicit declaration of function ‘wcwidth’ [-Wimplicit-function-declaration] temp = wcwidth (wc); ^ rm -f signals.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O signals.c rm -f util.o gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I. -DRL_LIBRARY_VERSION='"6.2"' -g -O util.c util.c: In function ‘_rl_tropen’: util.c:510:19: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘__pid_t {aka int}’ [-Wformat=] sprintf (fnbuf, "/var/tmp/rltrace.%ld", getpid()); ^ (略) rm -f tilde.so gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I.. -I.. -DRL_LIBRARY_VERSION='"6.2"' -g -O -fPIC -DREADLINE_LIBRARY -c -o tilde.o ../tilde.c mv tilde.o tilde.so rm -f compat.so gcc -c -DHAVE_CONFIG_H -DNEED_EXTERN_PC -fPIC -I. -I.. -I.. -DRL_LIBRARY_VERSION='"6.2"' -g -O -fPIC -o compat.o ../compat.c mv compat.o compat.so rm -f libreadline.so.6.2 gcc -shared -Wl,-soname,libreadline.so.6.2 -L./lib/termcap -Wl,-rpath,/usr/local/lib -Wl,-soname,`basename libreadline.so.6.2 .2` -o libreadline.so.6.2 readline.so vi_mode.so funmap.so keymaps.so parens.so search.so rltty.so complete.so bind.so isearch.so display.so signals.so util.so kill.so undo.so macro.so input.so callback.so terminal.so text.so nls.so misc.so xmalloc.so xfree.so history.so histexpand.so histfile.so histsearch.so shell.so mbutil.so tilde.so compat.so rm -f libhistory.so.6.2 gcc -shared -Wl,-soname,libhistory.so.6.2 -L./lib/termcap -Wl,-rpath,/usr/local/lib -Wl,-soname,`basename libhistory.so.6.2 .2` -o libhistory.so.6.2 history.so histexpand.so histfile.so histsearch.so shell.so mbutil.so xmalloc.so xfree.so make[1]: Leaving directory '/tmp/pip-build-a0t6v7b1/readline/rl/readline-lib/shlib' ============ Building the readline extension module ============ running install running build running build_ext building 'readline' extension creating build creating build/temp.linux-x86_64-3.6 creating build/temp.linux-x86_64-3.6/Modules creating build/temp.linux-x86_64-3.6/Modules/3.x gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_RL_CALLBACK -DHAVE_RL_CATCH_SIGNAL -DHAVE_RL_COMPLETION_APPEND_CHARACTER -DHAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK -DHAVE_RL_COMPLETION_MATCHES -DHAVE_RL_COMPLETION_SUPPRESS_APPEND -DHAVE_RL_PRE_INPUT_HOOK -I. -I/home/cloud/work/python3.6.0/sqlalchemy-tutorial/include -I/home/cloud/local/python3.6.0/include/python3.6m -c Modules/3.x/readline.c -o build/temp.linux-x86_64-3.6/Modules/3.x/readline.o -Wno-strict-prototypes Modules/3.x/readline.c: In function ‘PyInit_readline’: Modules/3.x/readline.c:1179:34: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types] PyOS_ReadlineFunctionPointer = call_readline; ^ creating build/lib.linux-x86_64-3.6 gcc -pthread -shared build/temp.linux-x86_64-3.6/Modules/3.x/readline.o readline/libreadline.a readline/libhistory.a -lncurses -o build/lib.linux-x86_64-3.6/readline.cpython-36m-x86_64-linux-gnu.so /usr/bin/ld: cannot find -lncurses collect2: error: ld returned 1 exit status error: command 'gcc' failed with exit status 1 ---------------------------------------- Command "/home/cloud/work/python3.6.0/sqlalchemy-tutorial/bin/python3.6.0 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-a0t6v7b1/readline/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-9mlhc520-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/cloud/work/python3.6.0/sqlalchemy-tutorial/include/site/python3.6/readline" failed with error code 1 in /tmp/pip-build-a0t6v7b1/readline/

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問