The pip list never ends.

Introduction

I built and installed Python 3.9 in an attempt to update Python 3 on my Raspberry Pi Zero W. Then, when I checked the list of installed packages with pip list, I encountered a symptom that it stopped without displaying a list or an error. Does it take time because it is Zero? I left it for a few hours, but it didn't change. I couldn't find the answer on the internet, so I will describe the solution here.

There is an additional note at the end. The root cause of this symptom was that the random numbers in the random number generator were exhausted by making a backup of the system and booting it with the duplicated SD card or changing the host name.

Symptoms

When I check the list of installed packages with pip list, nothing is displayed. If you stop with ^ C, the debug information will come out in a sloppy manner, and you can see that it was terminated around the inclusion of self._config = {'authkey': AuthenticationString (os.urandom (32)) ....

Confirmation

Start interactive mode with python3, enter the following, and if an error is returned, it is the same symptom. (I forgot to record the error. It was like `` `Resource temporarily unavailable```)

>>> import os
>>> os.getrandom(1, flags=os.GRND_NONBLOCK)
b'\xf9'(If this is okay. If there is a problem, you will get an error here)

Countermeasures

sudo mv /dev/random /dev/random.orig
sudo ln -s /dev/urandom /dev/random

This countermeasure, which has nothing to do with python or pip, was helpful. https://codz.me/2017/06/10/can-not-read-from-dev-random/

Postscript: Why did it happen? Is the measure appropriate?

Immediately before installing Python 3.9, I backed up the boot SD card, booted with the duplicated SD card, and changed the host name. Apparently, the pseudo-random numbers were exhausted (or initialized) in the process. Therefore, if it is a blocking random number, retries are repeated until random numbers are accumulated. The above countermeasure was an operation to force the use of an unlocked random number generator. As a side effect, biased random numbers can be used. After operating for a while and collecting enough random numbers, it seems that it is better to return to the original blocking random number generator. Reference: https://ja.wikipedia.org/wiki//dev/random

Recommended Posts

The pip list never ends.
Install the pip command
Extract the Azure service list
Pip install the GitHub repository
Methods available in the list
Supports pip list warning (DEPRECATION)
About the basics list of Python basics
Sort the list that contains the dict