LinuxUbuntu16.04 configuration repo

Ubuntu16.04 failed to configure repo

In the process of learning Wei Dongshan’s Linux embedded development, use the repo to obtain the kernel and tool chain:

git clone https://e.coding.net/codebug8/repo.git

mkdir -p 100ask_imx6ull-sdk & amp; & amp; cd 100ask_imx6ull-sdk

../repo/repo init -u https://gitee.com/weidongshan/manifests.git -b linux-sdk -m imx6ull/100ask_imx6ull_linux4.9.88_release.xml --no-repo-verify

../repo/repo sync -j4

The result failed, error message:

repo: warning: Python 2 is no longer supported; Please upgrade to Python 3.6 + .

No module named requests

Find the repo folder and open the repo file. My repo folder is in the home directory:

vim ~/repo/repo
def check_python_version():
  """Make sure the active Python version is recent enough."""
  def reexec(prog):
    exec_command([prog] + sys.argv)
 
  MIN_PYTHON_VERSION = (3, 6)
 
  ver = sys.version_info
  major = ver.major
  minor = ver.minor

Cause Analysis:

The Ubuntu16 system comes with python2.7 and python3.5. The default python version is python2.7, and requests are not installed. The script in the repo warehouse specified during repo init requires the python3.6 version interpreter, which will definitely cause problems when repo init is run.

python --version #View python default version

python2 --version #View python2 installation version

python3 --version #View python3 installation version

python3.5 --version #View python3.5 installation version

python3.8 --version #View python3.8 installation version

Remember, it is useless to use pip install requests here, because the default python versions of ubuntu16.04 are python2.7 and python3.5, and pip will still install the package. to the default python version, causing problems.

Please note that based on the blood and tears experience of others, the python that comes with the system must not be uninstalled! The correct approach is to install a higher version of python. Here I choose to install python3.8 directly. Reference links:

Environmental problems encountered by repo under ubuntu

Perfectly install the higher version of python and the corresponding version of pip under Ubuntu16.04

Method 1: Install python3.6 directly with the command (but I did not install it successfully)

It seems that the highest version of python in the Ubuntu16.04 software warehouse (source) is python3.5, so it cannot be installed directly using apt.

#Method 1
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6
#Method Two
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6

Reference links:
Ubuntu16.04, uninstalling the python3.5 that comes with the system caused a tragedy, but fortunately it was solved perfectly in the end

Perfect installation of python3.6.x (taking 3.6.9 as an example) and the corresponding version of pip under Ubuntu16.04

Method 2: Install from source code, install python3.8.11 here

 wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz
#To decompress, use the xfz command. It is not recommended to use -zxvf. Permission issues will not be explored in detail.
tar xfz Python-3.8.11.tgz
cdPython-3.8.11
./configure --with-ssl
make
sudo make install

Note: python3.8.11 will be automatically installed under /usr/local/bin, you can use update-alternatives to control the python version, easy to use!

After python3.6 is installed, you also need to install the corresponding version of pip. You can use the following command to check whether the pip corresponding to the python version is installed.

pip -V

pip2 -V
pip3 -V
pip3.8 -V
pip3.5 -V

If installed:

pip 21.1.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)

If it is not installed, you can use the following instructions. If it doesn’t work, just look it up on Baidu, it’s not difficult.

sudo apt-get install python3-pip #Install pip3

or

sudo apt install -y python3-pip

This is a Linux command that installs pip, the Python 3 package management tool. Among them, sudo is a command in Linux, used to execute a command as a super administrator. apt is a tool used in Linux distributions such as Ubuntu and Debian to manage software packages. install is a subcommand of apt, used to install software packages. The -y parameter indicates that manual confirmation is not required during installation. Here, we use apt to install the Python 3 package management tool pip, so that we can later use pip to install Python packages.

apt and apt-get have similar functions. In the opinion of professionals, it is worthwhile to choose apt because it provides all the necessary features for package management and is faster, more user-friendly and easy to use.

Use update-alternatives to set python priority

update-alternatives essentially manages soft links, but provides a more standardized and secure operation interface. This is just to build a simple version management, only one or two instructions are needed, and other functions will not be discussed in detail. First, check to see if it has been configured:

sudo update-alternatives --config python

In the above instructions, sudo requires sudo permission because it involves configuring soft links under /usr/bin;
–config is followed by the so-called service name, here it is python, which is the name of the set of version management you configured.

If “No candidate” is displayed, or it is incomplete, it means that you have not set the priority in this version series of “python”.

Priority example settings:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 2

In the above instructions,
/usr/bin/python is the name of the soft link to be created, which is shared by several versions;
The following python is the service name. The added version will be added to the version series named “python”. If it does not exist before (“no candidate”), it will be created;
The next /usr/bin/python2 is the actual location of the software;
The last number is the priority. You can choose automatic mode or manual mode later. In automatic mode, the version with the highest priority value will be automatically selected.

Note, My python3.8.11 will be installed under /usr/local/bin, so the correct method is as follows:

Adjust the priority of Python3 so that 3.8 has a higher priority

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1

sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.8 2

Now the system python defaults to Python2 and needs to be modified to Python3

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150

Result query:

remove link,

sudo update-alternatives --remove name path

Here we remove python3.8 from python3:

sudo update-alternatives --remove python3 /usr/local/bin/python3.8

Reference links:
Install python3 on ubuntu16.04
Linux command update-alternatives

subprocess.CalledProcessError: Command (lsb_release’, -a’)’ returned non-zero exit status 1

Reason: The ‘lsb_release.py’ module is missing in the python path.

solution:

1. Find the directory where the lsb_release module is located
sudo find / -name 'lsb_release.py'
 
2. Copy it to the system module loading location where python3.8 is set, which is the directory where the error report subprocess.py is located.
sudo cp /usr/lib/python3/dist-packages/lsb_release.py /usr/local/python/lib/python3.8/

Note that I adjusted it to my own path here:

sudo cp /usr/lib/python3/dist-packages/lsb_release.py /usr/local/lib/python3.8/

Reference links:

subprocess.CalledProcessError: Command (lsb_release, -a) returned non-zero exit status 1

Solution to python urllib3 v2.0 only supports OpenSSL 1.1.1 + , currently

uninstall

pip3 uninstall urllib3

re-install

pip install urllib3==1.23 -i https://pypi.tuna.tsinghua.edu.cn/simple

If that still doesn’t work, try upgrading openssl.

Problems when configuring the cross-compilation tool chain

export ARCH=arm
export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
export PATH=$PATH:/home/book/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin

Note that writing it directly like this is wrong. You need to replace book with your own user name:

export ARCH=arm
export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
export PATH=$PATH:/home/yugong/100ask_imx6ull-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin