我尝试使用以下命令从/usr/local/bin
中删除我的python2.7和python3文件夹:
sudo rm -rf python2.7
并且
sudo rm -rf python3
我的终端后来打不开了。我该怎么修复它?
当我将 Python 更新到 3.6 并选择另一种选项作为 python3.6 时,我遇到了同样的问题,但是当我将选项恢复为 python3.5 时,终端重新开始正常工作:
sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.6 2 auto mode
* 1 /usr/bin/python3.5 1 manual mode
2 /usr/bin/python3.6 2 manual mode
Press <enter> to keep the current choice[*], or type selection number:
我选择了1
,然后它开始工作。
你可以使用Virtual Studio Code或任何集成开发环境打开它的内部终端并运行命令来修复常见终端问题。
chroot
进行恢复。dpkg
手动安装它们(绕过需要Python的APT)。您可以按Alt+F2来运行应用程序。sudo apt-get update
&sudo apt-get install --reinstall ubuntu-desktop
或sudo apt-get install --reinstall python2.7
.bashrc
,因为每次运行终端时都会加载它。sudo apt-get update
命令。sudo apt-get dist-upgrade
命令。Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: No module named 'virtualenvwrapper')
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 and that PATH is
set properly.
看起来好像没有起作用。终端根本就没打开。在查阅了许多stackoverflow答案后我还是无法弄清楚。最终让我来告诉你我做了什么:
vi ~/.bashrc
# change version
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.6
source ~/.bashrc
sudo update-alternatives install /usr/bin/python python /usr/bin/python3.6 2
sudo update-alternatives --config python
1. CTRL + ALT + F1
2. 复制 ~/.bashrc 到 ~/.bashrc.bak
3. 复制 /etc/skel/.bashrc 到 ~/
4. 执行 source ~/.bashrc
如果终端无法使用 CTRL + ALT + F1,请尝试手动更改 .bashrc 文件的内容。
就我的情况而言
sudo apt-get install language-pack-en-base
sudo dpkg-reconfigure locales
locale -a
export LC_ALL="en.utf-8"
sudo nano /etc/default/locale
它应该是这样的
# File generated by update-locale
LANG="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
sudo apt install dconf-cli
dconf reset -f /org/gnome/terminal
sudo apt-get remove gnome-terminal
sudo apt-get install gnome-terminal
sudo locale-gen --purge
sudo dpkg-reconfigure locales
reboot