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**

Bing …

大约昨天(2021-Dec-16)下午开始注意到Bing (必应搜索) 出现访问困难。尝试了宽带和移动数据下的访问都是超时。一开始以为是DNS问题,换了后情况依旧。

今天还是和昨天一样无法访问。如果是DNS或者微软的服务器问题,不可能拖了那么久还没解决的。网上搜了下,发现原来不是个例。Bing自己也发布了一段简短的英文声明。

临时的方法

参考网上,目前暂时的解决方法,可以用备用的域名 www4.bing.com 进行访问。

或者可尝试修改hosts文件,把域名 www.bing.com cn.bing.com 对应的IP地址改为:204.79.197.200

结语

平时我自己是把Bing作为首选搜索引擎的。因为目前“普通的”上网姿势下,Bing比某度好用多了,广告少,并且外文关键字搜索能力也好得多。但愿这点事不会拖得太久,最终可以解决。要是Bing变成Google的待遇,那就实在太恶心人了。

附:

有关报道:https://www.ithome.com/0/592/920.htm

Bing自己也发布了一段简短的说明:

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.