can't open software sources, software manager etc

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
hom_tanks
Level 1
Level 1
Posts: 22
Joined: Fri Sep 01, 2017 12:13 pm

can't open software sources, software manager etc

Post by hom_tanks »

Hi

I haven't used my LM distro in a while and I recently ran into some issues with trying to install some codecs for a project, so I tried to clean up some repo errors that I get with "sudo apt update". Now I am down a rabbit hole where I cannot open things like "software sources" from the UI.

I've been using LM 20 and the machine currently has LM 20.3. I'm somewhat guilty of having installed many ppas on this machine over time as and when the need arose, and not maintaining them cleanly as life got in the way, started using another OS, something else was more urgent yada yada. I now want to clean up my Linux Mint installation for once and for all.

Here's the output of software-properties-gtk , which was suggested as a troubleshooting step in a different post by someone. I don't know where to begin. Any help or pointers would be great!

Code: Select all

mymachine:~$ software-properties-gtk 
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (2.0.7) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (2.0.7) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
  File "/usr/lib/linuxmint/mintSources/mintSources.py", line 11, in <module>
    import requests
  File "/usr/lib/python3/dist-packages/requests/__init__.py", line 95, in <module>
    from urllib3.contrib import pyopenssl
  File "/usr/local/lib/python3.8/dist-packages/urllib3/contrib/pyopenssl.py", line 43, in <module>
    import OpenSSL.SSL  # type: ignore[import]
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1553, in <module>
    class X509StoreFlags(object):
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1573, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 72, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 32, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 12, in <module>
    import os, glob, subprocess, os.path, time, pwd, sys, requests_unixsocket
  File "/usr/lib/python3/dist-packages/requests_unixsocket/__init__.py", line 1, in <module>
    import requests
  File "/usr/lib/python3/dist-packages/requests/__init__.py", line 95, in <module>
    from urllib3.contrib import pyopenssl
  File "/usr/local/lib/python3.8/dist-packages/urllib3/contrib/pyopenssl.py", line 43, in <module>
    import OpenSSL.SSL  # type: ignore[import]
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1553, in <module>
    class X509StoreFlags(object):
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1573, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'

PS: This wiki suggests how to repair the sources list for 21.3. https://easylinuxtipsproject.blogspot.c ... urces.html

I am not sure how to apply this for 20.3, and I don't want to further corrupt an already funky installation. But if someone can suggest the solution for 20.3, I can definitely try it. However, I am not sure if just fixing the sources will fix all the mess that already have been incurred. Should I reinstall the distro and start from scratch? It will mean I may have to reinstall a lot of stuff I had on here but that's a price I am willing to pay if nothing else more elegant is available .
billyswong
Level 8
Level 8
Posts: 2240
Joined: Wed Aug 14, 2019 1:02 am

Re: can't open software sources, software manager etc

Post by billyswong »

This looks like a result of pip and/or some other Python related package mess up.

The Python packages ecosystem is yet another dependency hell, perhaps more fragile than the apt/deb ecosystem (at least apt will warn people for or block people from installing/upgrading stuff that are known to be incompatible to existing software). Yet most instructions on the web ignore this issue and push people to download/install naively. I were guilty for such once before too :oops:

See viewtopic.php?t=362499 for how to utilize pyenv to contain the madness. Then run pip only on top of that (e.g. https://stackoverflow.com/questions/611 ... -i-created)

----

In Linux Mint, software-properties-gtk will just redirect you to pkexec mintsources, same as you clicking the "software sources' button from GUI. Then mintsources will redirect you to /usr/lib/linuxmint/mintSources/mintSources.py

Therefore, if your Python system environment is messed up, many GUI utilities provided by Linux Mint such as this one will fail to load.

If you haven't "upgraded" the system Python version, then script such as https://haykot.dev/blog/til-how-to-reset-python-env/ may be enough to restore stuff.
TIL How to Reset Python Environment

I recently had to recover my system python after a mistaken pip install command and I thought I’d share the script I used to do it.

This script will:
  1. Check if pip or pip3 is the correct command to use
  2. Run pip freeze to get a list of all installed packages and save it to a temporary file
  3. Read the temporary file line by line and uninstall each package

Code: Select all

#!/bin/bash

# Check if pip or pip3 is the correct command to use
if command -v pip &> /dev/null; then
  PIP_CMD="pip"
elif command -v pip3 &> /dev/null; then
  PIP_CMD="pip3"
else
  echo "Error: pip or pip3 command not found."
  exit 1
fi

# Create a temporary file to store the list of installed packages
TMP_FILE=$(mktemp)

# Get a list of all installed packages and save it to the temporary file
$PIP_CMD freeze > "$TMP_FILE"

# Loop over each package and uninstall it
while read package; do
  echo "Uninstalling package: $package"
  $PIP_CMD uninstall -y $package
done < "$TMP_FILE"

# Remove the temporary file
rm "$TMP_FILE"

echo "All packages have been uninstalled."
----

Synaptic package manager, the older GUI tool, should still be runnable in your computer. Try downgrade your Python from there if you need so. There is a Package > Force Version feature there.
hom_tanks
Level 1
Level 1
Posts: 22
Joined: Fri Sep 01, 2017 12:13 pm

Re: can't open software sources, software manager etc

Post by hom_tanks »

Thank you @billyswong

/usr/bin/python is pointing to python3, and /usr/bin/python2 is pointing to python 2.7. Its been a while, quite possible I upgraded it but not sure if it was via "pip install"

I guess in future , I would resort to pyenv or virtualenv but how do I fix the current issues? Short of removing all trace of python3 , is there any way to make the system utilities work with python3?
billyswong
Level 8
Level 8
Posts: 2240
Joined: Wed Aug 14, 2019 1:02 am

Re: can't open software sources, software manager etc

Post by billyswong »

No, I am talking about more detailed versioning such as what shows up in apt version python3.

For LM 20.x, it should be 3.8.x
For LM 21.x, it should be 3.10.x
hom_tanks
Level 1
Level 1
Posts: 22
Joined: Fri Sep 01, 2017 12:13 pm

Re: can't open software sources, software manager etc

Post by hom_tanks »

Code: Select all

mymachine:~$ apt version python3
3.8.2-0ubuntu2
mymachine:~$ apt version python2
2.7.17-2ubuntu4

So it seems to be set correctly. However nothing is set for "apt version python". Is that ok?

Also, the actual python minor version seems to differ from what's in apt

Code: Select all

mymachine:~$ python --version
Python 3.8.10
Finally, if I have to goto the final resort of removing python3 entirely, would you say doing it from Synaptic is the most failsafe? How would I do it - just search for python3 and remove all packages that show up?

Is it worth trying to change the system symlink to point to python2 (below diagram)

[img]file://tmp/Screenshot%20from%202024-03-27%2009-27-36.png[/img]
Attachments
Screenshot from 2024-03-27 09-27-36.png
billyswong
Level 8
Level 8
Posts: 2240
Joined: Wed Aug 14, 2019 1:02 am

Re: can't open software sources, software manager etc

Post by billyswong »

No, you shouldn't remove python3. Python3 is the default python for years now. Your base package is definitely the standard installation from Ubuntu repository.

Rereading your error log, your problem seems to be some library modules within Python that got over-upgraded. I found Python urllib3 is versioned 1.25.8 in LM 20.3 live ISO and 1.26.5 in LM 21.3 live ISO. Yet in your log it is shown to be versioned 2.0.7. It make sense that major version upgrade may introduce backward-incompatible change.

Edit: In Synaptic, search for package python3-urllib3. This should be the package you need to downgrade / lock version for.
hom_tanks
Level 1
Level 1
Posts: 22
Joined: Fri Sep 01, 2017 12:13 pm

Re: can't open software sources, software manager etc

Post by hom_tanks »

Corrupt OpenSSL was the culprit. Removing the corrupted module solved the issue. https://stackoverflow.com/questions/778 ... r-check-py

Thanks billyswong for pointing me in the right direction - ultimately lead me to the fix.

Cheers!
billyswong
Level 8
Level 8
Posts: 2240
Joined: Wed Aug 14, 2019 1:02 am

Re: can't open software sources, software manager etc

Post by billyswong »

Oh good to hear. So it is removing python3-openssl that solves the problem?
hom_tanks
Level 1
Level 1
Posts: 22
Joined: Fri Sep 01, 2017 12:13 pm

Re: can't open software sources, software manager etc

Post by hom_tanks »

Yes, sorry should've been more specific. The following commands did it.

Code: Select all

sudo apt purge python3-openssl
sudo apt autoremove
It appears that python3-openssl has openssl bindings for python and something in there was conflicting with the stock openssl toolkit (this is my best guess, I could be wrong). Now that I have removed it, I have a nagging feeling that I may run into problems in future with my python installation with some specific SSL-related usecase, who knows :D . But we'll cross that bridge when we get to it. On a flip side, my pip also was broken before but it seems to work fine now.
Post Reply

Return to “Software & Applications”