A Solution for “No module named ‘apt_pkg’” Error in Ubuntu 22.04

If you encounter the “No module named ‘apt_pkg’” error while trying to use the apt update command in Ubuntu 22.04, it might be because the default python3 version in the system is too new. In this case, the default version is 3.11, and changing it to 3.10 solved the problem.

Here are the steps to do this:

  1. Check the current Python 3 version by running the following command:
python3 --version
  1. If the version is 3.11, try using the following command to change it:
sudo update-alternatives --config python3
  1. If the above command returns an error like “update-alternatives: error: no alternatives for python3,” it means there are no alternatives set for Python 3. Ensure that Python 3.10 is installed on your system. It’s usually located at /usr/bin/python3.10
  1. Add Python 3.10 as an alternative using the following command:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
  1. Run the update-alternatives command again to choose Python 3.10 as the default:
sudo update-alternatives --config python3

This solution sets Python 3.10 as the default Python 3 version in your system, which should resolve the issue with the apt update command.

Remove Rounded corners for player and thumbnail on YouTube website

The recent UI change on the YouTube website has been causing some annoyance among users. Unfortunately, there is no option to choose whether to use rounded corners or not.

The CSS style below controls the corner of the player:

ytd-watch-flexy[rounded-player-large][default-layout] #ytd-player.ytd-watch-flexy {
    overflow: hidden;
    border-radius: 12px;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    border-bottom-right-radius: 12px;
    border-bottom-left-radius: 12px;
}

The style “border-radius” defines the size of rounded corner of the player.
So, to disable the rounded corners you just need to disable or change the correspond CSS style.

Here is the example to restore right-angled corners for player by using uBlock Origin extension:

  1. Open the dashboard of uBlock Origin.
  2. Enter the following code into the “My Filters” section:
www.youtube.com##.ytd-watch-flexy:style(border-radius: 0px!important;)

“border-radius: 0px” means no rounding is done and the corner is square.

To remove rounded corners for thumbnails, add following code:

www.youtube.com##.ytd-thumbnail:style(border-radius: 0px!important;)

A regular BIOS update turned into a pain in the a**

Just found out that my 3-year-old Intel NUC8 has got a new BIOS release 0090 recently. I downloaded and upgraded it without think twice (which is going to waste some of my time later.)

I have two OS installed and dual boot configured on the hard drive. Windows 10 alongside with Ubuntu Desktop. By default, it will boot into GRUB menu by default, where I can choose whether or not to boot into Windows.

I have done BIOS update for this NUC several times before. But this time, after the new BIOS update, the machine boot directly into Windows without showing the GRUB menu. I tried to hit F10 on-boot to bring up the Boot selection menu to choose another EFI boot-loader — but something weird is: There is only one “Windows Boot Manager” up there, the “ubuntu” boot entry is missing.

Continue reading A regular BIOS update turned into a pain in the a**

Issues when trying to get Let’s Encrypt certificate signed for a website behind Cloudflare CDN.

[ 浏览本文的中文版. ]

Recently I enabled Cloudflare CDN for a website. At the beginning, everything went fine. Until there is one day, I was trying to renew the Let’s Encrypt certificate for the domain by using the acme_tiny.py program, which I always use. However, this time it fails again and again, on the error: cannot download http://****/.well-known/acme-challenge/**** .

In short, before issuer (Let’s Encrypt) signs the certificate, this program will generate a challenge file in a specified path under the domain. Then issuer will try to fetch the challenge file, to make sure the requester is the real owner of the domain.

I tried use wget to download the challenge file, and got a 404 error. By break down the wget output, I found that, when request the challenge file via http, the request was redirected to https, that is the cause of the error. Because the origin server only have acme-challenge configured on port 80, so when you trying to access it from https the only thing you will get is the 404 error.

Because I always use the program to renew certificates, so this time I wonder if it is the CDN caused the error.

In addition, one thing makes me feel weird is, the origin server not have https rewrite configured for the acme-challenge path, so why the http request is being redirected to https automatically? After some digging around, trying to adjust some Cloudflare options, finally, I found out: the option “Always Use HTTPS” (under the SSL/TLS –> Edge Certificates section) is the root cause of this error. With this option turned on will redirect all http requests to https automatically. That is why the http request to fetch acme-challenge file got redirected to https.

After turned off this option, the acme_tiny.py program worked flawlessly like before and I got the Let’s Encrypt certificate renewed successfully.

Conclusion for this time, when have CDN enabled for a website; the configurations of the CDN might cause some unexpected issues to happen, like this time. When the origin server is not the cause of the problem, should turn to investigating CDN’s configurations, to figure out whether the CDN is the causing the problem.

Cloudflare option under SSL/TLS -> Edge Certificates: always use HTTPS.

File System directory of Chrome browser took a lot of disk space

When I was cleaning up my computer’s disk space, I noticed that the Chrome directory under AppData\Local\Google took almost 10 GB spaces, especially the directory File System, which is using 7.87 GB of disk space. In the File System directory, one largest directory used most of the space named 017. In this directory there are 9 very large files in it, each one is around 900 MB, and all of them were created on last November.

The “File System” directory used 7.87 GB of disk space.

After googling around, I found this article is useful:

https://www.ghacks.net/2015/06/24/hard-drive-filling-up-check-chromes-file-system-folder/

Quote: “Chrome (and Chromium) use the folder to store files stored with the help of the File System API which is part of HTML5.”

So, it looks like some web service were using File System API stored these data on the disk. But I can’t remember which website I used could take up almost 8 GB data on my disk.

Only thing I can do now is to delete these files, and monitor the File System directory frequently to see if there is any unusual amount of space used by this directory.