Jayanth
Jayanth

Reputation: 329

Terminal window not working Ubuntu after uninstalling Python folders

I tried removing my python2.7 and python3 folders from /usr/local/bin by using a command:

sudo rm -rf python2.7

and

sudo rm -rf python3

Later my terminal is not opening. How can I fix it?

Upvotes: 3

Views: 39218

Answers (7)

AniketGole
AniketGole

Reputation: 1295

GO to Setting -> Region & Language -> Login screen -> change language to English(United State) and restart

Before Change

enter image description here

After change enter image description here

Hope your issue fixed !!!

Upvotes: 0

Bambier
Bambier

Reputation: 864

In my case

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

and it shoud be

#  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"

outherwise

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

Upvotes: 0

Fares Karbia
Fares Karbia

Reputation: 55

1 CTRL + ALT + F1

2 cp ~/.bashrc ~/.bashrc.bak

3 cp /etc/skel/.bashrc ~/

4 source ~/.bashrc

if terminal not working with CTRL + ALT + F1, try to change the content of .bashrc manually

Upvotes: 0

Aahad
Aahad

Reputation: 577

I was having the same issue when I updated python to 3.6 and selected alternative as python3.6, but when I reverted the option to the python3.5, terminal started working again:

sudo update-alternatives --config python3

The following message popped up:

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:

I selected 1 and it started working.

You can use Virtual Studio Code or any IDE to open it's internal Terminal and run the command to fix the common Terminal.

Upvotes: 9

Shreyas S
Shreyas S

Reputation: 11

I will list what caused my problem and how I fixed it. Python version in my terminal was 2.7 and to upgrade it to 3+.
You might have got this message as well

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.

It didn't seem to have worked. Then terminal wasn't opening at all. After going through many stackoverflow answers I couldn't figure out. At the end let me tell what I did :

  1. Change python version in ~/.bashrc file.
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

The number 2 is user choice in my case there were two python versions. After executing both commands it will show a list of versions Select the python version from .bashrc file in auto mode

For me this worked!!!

Upvotes: 1

DerMann
DerMann

Reputation: 243

  1. Install PyCharm.
  2. Open PyCharm terminal.
  3. Run sudo apt-get update.
  4. Run sudo apt-get dist-upgrade.

Upvotes: 3

Keivan
Keivan

Reputation: 762

You do not specify how deep your problem goes here. You also don't mention what you have already tried and which solutions do not work.

Ubuntu depends on Python, so removing it messes up with your system. When you force rm to remove Python, obviously you don't get a warning what the effects will be, but doing this in via apt would have shown you. A similar issue is also discussed here.

Here there are some solutions:

  • You can reinstall your Ubuntu.
  • You can recover using live CD using chroot
  • Try to run some other package manager like Synaptic (if they are installed) and reinstall Python 2.7
  • Manually download Python 2.7 package (and its dependencies), and manually install them using dpkg (bypassing APT, which requires Python). You can press Alt+F2 to run an application.
  • Can you go to the virtual consoles by pressing Ctrl+Alt+F1 or F6 (you can get back to the window manager by Ctrl+Alt+F7)? If yes, then you can login with your user pass and see if you can run sudo apt-get update & sudo apt-get install --reinstall ubuntu-desktop or sudo apt-get install --reinstall python2.7
  • I would also have a look in .bashrc as it is loaded every time you run the terminal.

Upvotes: 4

Related Questions