'Can't uninstall global python3.5 module after upgrading to python3.6

I recently upgraded from Ubuntu 17.04 to 17.10 in order to be able receive the patches for meltdown. This upgrade automatically bumped me from python3.5 to python3.6, which I don't have any problem with. However, I do have to go through and reinstall all the little tools I used. One is being troublesome.

I use a tool called tmuxp, and the official install instructions are pip install --user tmuxp. However, it seems that some time ago I install tmuxp globally on my python3.5, and it now has an executable in my /user/local/bin:

➜ maynard@buddha  ~  which tmuxp
/usr/local/bin/tmuxp

This means that even after running pip install --user tmuxp, when I run tmuxp I get a DistributionNotFound error.

➜ maynard@buddha  ~  tmuxp
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 658, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 972, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 863, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (tmuxp 1.3.5 (/home/maynard/.local/lib/python3.6/site-packages), Requirement.parse('tmuxp==1.3.2'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/tmuxp", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3049, in <module>
    @_call_aside
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3033, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3062, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 660, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 673, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 858, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'tmuxp==1.3.2' distribution was not found and
is required by the application

So the old python3.5 tmuxp binary is going and looking in the new python3.6 site-packages for an older version of itself. This should be an easy fix. Simply uninstall the python3.5 version of tmuxp. But when I use pip3.5 is tries to uninstall the python3.6 tmuxp.

pip3.5 uninstall tmuxp
Uninstalling tmuxp-1.3.5:
  /home/maynard/.local/bin/tmuxp
  /home/maynard/.local/lib/python3.6/site-packages/tmuxp-1.3.5.dist-info/DESCRIPTION.rst
  ...
  /home/maynard/.local/lib/python3.6/site-packages/tmuxp/workspacebuilder.py

In fact, a pip3.5 list doesn't even show tmuxp, but I can see it in /usr/local/lib/python3.5/dist-packages!

ls /usr/local/lib/python3.5/dist-packages
click                     kaptan                  powerline
click-6.7.dist-info       kaptan-0.5.8.egg-info   powerline_status-2.6.egg-info
colorama                  libtmux                 tmuxp
colorama-0.3.9.dist-info  libtmux-0.7.4.egg-info  tmuxp-1.3.2.egg-info

Invoking sudo doesn't work either. sudo ~/.local/bin/pip3.5 uninstall tmuxp once again tries to uninstall the python3.6 version of tmuxp.

I know I could just delete the binary in /usr/local/bin/tmuxp... But I want to know how I got myself into this mess and how I can get out of it cleanly.



Solution 1:[1]

tmuxp didn't exist officially in Ubuntu until 18.04 bionic (LTS).

/usr/lib/python3/dist-packages

Do you have tmuxp installed through apt / apt-get through some other method? If so, see what sudo apt-get remove tmuxp does.

If you don't have the apt package to tmuxp, I'm concerned about your system's python installation.

Backtracking using history(1) + grep(1)

To find out how and why the system's python packages got borked depends on the commands you ran in the past. Hopefully you still have a shell history of when you installed.

If you look in your Bash history for tmuxp by piping to grep(1), e.g. history | grep tmuxp, can you see commands for how you could have ended up with it previously?

My hunch is you may have used easy_install, which in 2022 isn't used anymore.

Cleaning up old packages

I prefer clean installs over upgrades with Ubuntu, namely to avoid issues like this. It's not as painful in recent releases.

@hoefling's comment is on track. It seems you need to install python 3.5 again. This answer has some ways to get 3.5 working again. Afterwards, you can then install it.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tony N