Bottom Tab bar has an ever increasing number of tabs when Deleting python2.7

So recently I have been trying to do some web development with django framework. Initially, I had python 2.7 installed on my lenovo laptop… and whenever I ran the python command it would reference to that folder, /usr/lib/python2.7, but… when I tried to get django working It wasnt compatible with python 2.7… so I deleted 2.7 and installed 3.5. I then tried the python command, but the following error was given…

Could not find platform independent libraries
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to [:<exec_prefix>]
ImportError: No module named site

I then restarted my laptop.

When it restarted, the bottom tab bar had an ever increasing number of tabs poping up with the tag ‘starting cache’ written on it. The number of tabs keep on increasing until I shut down my laptop. Also, all of my icons on my home screen have dissapeared and initially when the laptop is booting up the homepage is black… it doesnt show the background screen.

Whether my downloading of python 3.5 and removal of 2.7 caused this, I am not sure. I have had cases in the past when booting up my laptop that the icons on the home-screen did not load up.

I have tried to get rid of python 3.7 on my laptop with ‘sudo apt-get remove python3.7’

but a longer version of this repetitive error is given…
error - {
dpkg: error processing package python3-requests (–configure):
** dependency problems - leaving unconfigured**
No apport report written because MaxReports is reached already
** dpkg: dependency problems prevent configuration of python3-smbc:**
** python3-smbc depends on python3 (<< 3.6); however:**
** Package python3 is not configured yet.**
** python3-smbc depends on python3 (>= 3.4~); however:**
** Package python3 is not configured yet.**

dpkg: error processing package python3-smbc (–configure):
** dependency problems - leaving unconfigured**
No apport report written because MaxReports is reached already
** dpkg: dependency problems prevent configuration of python3-sqlparse:**
** python3-sqlparse depends on python3:any (>= 3.3.2-2~); however:**
** Package python3 is not configured yet.**

dpkg: error processing package python3-sqlparse (–configure):
** dependency problems - leaving unconfigured**
No apport report written because MaxReports is reached already
** dpkg: dependency problems prevent configuration of python3-tz:**
** python3-tz depends on python3:any (>= 3.3.2-2~); however:**
** Package python3 is not configured yet.**

dpkg: error processing package python3-tz (–configure):
** dependency problems - leaving unconfigured**
dpkg: too many errors, stopping
No apport report written because MaxReports is reached already
** Errors were encountered while processing:**
** gufw**
** python3**
** python3-apt**
** python3-dbus**
** language-selector-common**
** ubuntu-drivers-common**
** python3-chardet**
** python3-debian**
** update-notifier-common**
** lsb-release**
** python3-gdbm:amd64**
** python3-commandnotfound**
** python3-distupgrade**
** python3-update-manager**
** python3-gi**
** ubuntu-release-upgrader-core**
** update-manager-core**
** apport**
** apport-gtk**
** gconf2**
** python3-defer**
** python3-aptdaemon**
** python3-aptdaemon.gtk3widgets**
** apturl**
** gdebi-core**
** libgksu2-0**
** gksu**
** gdebi**
** python3-brlapi**
** python3-cairo**
** gnome-orca**
** hplip-data**
** language-selector-gnome**
** lightdm-gtk-greeter-settings**
** python3-gi-cairo**
** onboard**
** python3-blinker**
** python3-cffi-backend**
** python3-cffi**
** python3-configobj**
** python3-cryptography**
** python3-django**
** python3-lxml**
** python3-oauthlib**
** python3-pexpect**
** python3-pil:amd64**
** python3-reportlab**
** python3-requests**
** python3-smbc**
** python3-sqlparse**
** python3-tz**
Processing was halted because there were too many errors.E: Sub-process /usr/bin/dpkg returned an error code (1)
}

Not sure what to do here. I was considering reinstalling my os since I did’nt take any snapshots of the system, which I should have done.

Any Help is much appreciated!

Ouch, @seanieMc! I feel for you, you have just broken your system when you removed Python 2.7.

###The problem
Distros today are heavily dependent on Python. A lot of their functionality is tightly integrated with the the python interpreter, starting right with the installation process and down to core functionality of the desktop environment.

If you ask me, I find all that a disgrace, because it forces anyone interested on Python development in Linux to maintain redundant local versions of Python on their home folder. On the other hand, this has allowed distros to offer great many features. I have no doubt in my mind when I claim that the Python language is the major reason why Linux today can be offered to users with such an easy installation procedure and with such a rich working environment right out of the box. The benefits far outweigh the one (minor?) disadvantage faced by the python development community.

###The solution
I cannot give you advise on how to fix your system. The integration with Python is so tight, that I don’t really want to advise you to try and install Python 2.7 again. There would also be the matter of the python third-party packages that you would need to install on top of Python 2.7 and frankly that’s one hell of a job to do right.

Better you just do all the necessary backups of your $HOME and reinstall Ubuntu-MATE. I know, it’s a pain. While it is true that unless you have a defective disk, Linux never requires a full reinstall. No matter the problems you face, Linux is always recoverable. But it is also true that a comprehensive guide to recover Python 2.7 in your machine is a hard to do and do right. By the time we finally finished with it and had gone through all the dependencies that other software that you installed in the meantime might have created, you would have installed tenths of machines from the Ubuntu-MATE Live CD. So, in the name of speed, efficiency and sanity, just backup what you need from your $HOME directory and reinstall Ubuntu-MATE.

###The prevention (aka Python Development in Linux the right way)
You may be wondering though that none of this will solve the problem that got you into this mess in the first place, and that is essentially: How to develop in Python on Ubuntu-MATE?

The answer is simple and applies to any other distro out there (with only a few exceptions that actually don’t depend on python).

You never, ever, develop in Python using the system python installation. For all purposes and effects you should pretend it doesn’t even exist. The “system python” is meant to be system exclusive, updated by it through the normal package update mechanisms in Ubuntu-MATE, and otherwise entirely maintained and used solely by the system.

Instead what you should do is install a so-called Local Python Environment, which is essentially python installed on your $HOME directory. And that’s the python you use to develop for. So, if you wish to learn Django, you install Python “locally” and then install Django with that Python pip command.

A few excellent tools help you create these local python environments. Pythonz is a popular one and also pyenv. I use pyenv myself and you can find an excellent tutorial on how to install and use it here.

These are easy to use tools that do all the heavy-lifting for you and will help change completely the way you work in python in a way that is entirely safe and that doesn’t disturb your system python. For instance, this is what you would need to do to get started:

# go to your home folder
$ cd
# install pyenv
$ curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
# Install python 2.7 and 3.5
$ pyenv install 2.7.12
$ pyenv install 3.5.2
# activate your python 3.5
$ pyenv global 3.5.2
# install Django
$ pip install django

Not only you can now download and maintain your specific versions of Python, but you can also obtain the latest versions of both Python and python packages and isolate entirely your development environment from the prickly system Python that is best left alone.

3 Likes

Thank you very much for replying marfig with such comprehensive feedback… Much Appreciated. I had the feeling that I needed to reinstall my os… was just curious as to whether I was possibly missing something obvious… some sort of quick fix… but it’s obvious now that no such escape exists!!!

@marfig is right . But you don’t have to uninstall python2.7 to install python 3.5 since they not conflict (Different folders for difirent versions) . Just install them both . You as developer should know that whenever a scripts is created you have to specify interpreter path . In Ubuntu python 2 is symlinked as python and python 3 as python3.
Likely django has enterpreter path of #!/usr/bin/env python3 in wich case it is looking for python3 .
So the forcing to use specific version of python is false statement .

For trying to fix your OS do :

sudo apt-get install --reinstall ubuntu-mate-meta

wich will reinstall ubuntu-mate and pull missing dependencies .

1 Like