ubuntu14 python3解释器不能方向键

1,参照:https://blog.csdn.net/xlf13872135090/article/details/25986509
$ sudo apt-get install libreadline6-dev
报错:
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in <module>
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
dpkg: error processing package python-py (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python-pytest:
python-pytest depends on python-py (>= 1.4.19); however:
Package python-py is not configured yet.


原因可能是系统同时有python2和python3, 而apt-get默认python2
2,设置为Python3为默认(不清楚是否起作用)
参照:https://blog.csdn.net/setoy/article/details/78587723
sudo update-alternatives --install /usr/bin/pythonpython/usr/bin/python2 100
sudo update-alternatives --install /usr/bin/pythonpython/usr/bin/python3 150
update-alternatives --config python

3,安装错误提示中需要的软件包
从:https://packages.ubuntu.com/
下载python3-py,python3-pytest, libreadline6-dev安装
$ sudo dpkg -i Downloads/python3-py_1.4.20-1_all.deb
$ sudo dpkg -i Downloads/python3-pytest_2.5.1-1_all.deb
$ sudo dpkg -i Downloads/libreadline6-dev_6.3-4ubuntu2_amd64.deb

重新编译python3:
$ cd Python-3.6.4/
$ ./configure
$ make
$ sudo make install

成功,python3中使用方向键正常


注:因为libreadline6-dev用apt-get和pip3都不能直接下载安装,只能一个个安装

猜你喜欢

转载自blog.csdn.net/heybob/article/details/82775176