Table of contents
1. ImportError: No module named google.protobuf
Use the tools that come with the Android source code to perform OTA upgrades, and the error is as follows:
sun@sun-pc:~/nvme0/AOSP$ python system/update_engine/scripts/update_device.py out/dist/ota_package.zip
Traceback (most recent call last):
File "system/update_engine/scripts/update_device.py", line 34, in <module>
import update_payload.payload
File "/home/sun/nvme0/AOSP/system/update_engine/scripts/update_payload/__init__.py", line 20, in <module>
from update_payload.checker import CHECKS_TO_DISABLE
File "/home/sun/nvme0/AOSP/system/update_engine/scripts/update_payload/checker.py", line 37, in <module>
from update_payload import common
File "/home/sun/nvme0/AOSP/system/update_engine/scripts/update_payload/common.py", line 21, in <module>
from update_payload import update_metadata_pb2
File "/home/sun/nvme0/AOSP/system/update_engine/scripts/update_payload/update_metadata_pb2.py", line 7, in <module>
from google.protobuf import descriptor as _descriptor
ImportError: No module named google.protobuf
Solution:
The currently used python version is 2.7, and the problem can be solved by installing the corresponding version of the protobuf module.
sun@sun-pc:~/nvme0/AOSP$ python -m pip install protobuf==3.17.3 #如果是python3有问题,就把这里的python改为python3
Collecting protobuf==3.17.3
Downloading https://files.pythonhosted.org/packages/e9/06/5606088c9fbfb924d0f228350e7ec8707fe8f8a6f3a024ace4f0da81d9ce/protobuf-3.17.3-cp27-cp27mu-manylinux_2_5_x86_64.manylinux1_x86_64.whl (1.0MB)
100% |████████████████████████████████| 1.0MB 22kB/s
Collecting six>=1.9 (from protobuf==3.17.3)
Downloading https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl
Installing collected packages: six, protobuf
Successfully installed protobuf-3.17.3 six-1.16.0
2. TypeError: a bytes-like object is required, not ‘str’
When executing repo upload, the python script reported a type error
sun@sun-pc:~/code/AOSP/QSSI/packages/apps/Launcher3$ repo upload .
Upload project QSSI/packages/apps/Launcher3/ to remote branch AOSP:
branch master ( 1 commit, Fri Oct 14 09:55:46 2022 +0800):
b'1126d9bd \xe3\x80\x90\xe5\x88\x86\xe6\x94\xaf\xe5\x90\x8d\xe7\xa7\xb0\xe3\x80\x91\xef\xbc\ \xe3\x80\x90\xe5\xae\xa2\xe6\x88\xb7\xe5\x90\x8d\xe7\xa7\xb0\xe3\x80\x91\xef\xbc\x9a \xe3\x80\x90\xe4\xbf\xae\xe6\x94\xb9\xe6\x8f\x8f\xe8\xbf\xb0\xe3\x80\x91\xef\xbc\x9a\xe4\xbf\xae\xe5\xa4\x8d\xe9\xa6\x96\xe6\xac\xa1\xe5\xbc\x80\xe6\x9c\xba\xe7\x82\xb9\xe5\x87\xbb\xe4\xbb\xbb\xe5\x8a\xa1\xe9\x94\xae\xe9\x97\xaa\xe9\x80\x80 \xe3\x80\x90\xe8\xb4\xa3\xe4\xbb\xbb\xe4\xba\xba\xe5\x91\x98\xe3\x80\x91\xef\xbc\x9asun \xe3\x80\x90\xe9\x97\xae\xe9\xa2\x98\xe5\x8d\x95\xe5\x8f\xb7\xe3\x80\x91\xef\xbc\x9a666\n'
y
to http://192.32.1.23:8080 (y/N)? Traceback (most recent call last):
File "/home/sun/code/AOSP/.repo/repo/main.py", line 547, in <module>
_Main(sys.argv[1:])
File "/home/sun/code/AOSP/.repo/repo/main.py", line 522, in _Main
result = repo._Run(argv) or 0
File "/home/sun/code/AOSP/.repo/repo/main.py", line 184, in _Run
result = cmd.Execute(copts, cargs)
File "/home/sun/sata/home/sun/project/AOSP/.repo/repo/subcmds/upload.py", line 504, in Execute
self._SingleBranch(opt, pending[0][1][0], people)
File "/home/sun/sata/home/sun/project/AOSP/.repo/repo/subcmds/upload.py", line 232, in _SingleBranch
self._UploadAndReport(opt, [branch], people)
File "/home/sun/sata/home/sun/project/AOSP/.repo/repo/subcmds/upload.py", line 401, in _UploadAndReport
push_options=opt.push_options)
File "/home/sun/sata/home/sun/project/AOSP/.repo/repo/project.py", line 193, in UploadForReview
push_options=push_options)
File "/home/sun/sata/home/sun/project/AOSP/.repo/repo/project.py", line 1152, in UploadForReview
url = branch.remote.ReviewUrl(self.UserEmail, validate_certs)
File "/home/sun/sata/home/sun/project/AOSP/.repo/repo/git_config.py", line 659, in ReviewUrl
if info == 'NOT_AVAILABLE' or '<' in info:
TypeError: a bytes-like object is required, not 'str'
Solution:
perform type conversion on the info returned in line 658, and convert it to str type.
info = info.decode() #将bytes类型转化为str类型
3. ImportError: No module named ‘_ssl’
Situation 1
This error was reported when pyenv installed pythonc.
sun@sun-pc:~$ pyenv install 3.5.0
Installing Python-3.5.0...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/src/pyenv/versions/3.5.0/lib/python3.5/ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: No module named '_ssl'
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
Solution:
install libssl1.0-dev can be solved.
sudo apt-get install libssl1.0-dev
Situation 2:
This error was reported when pyenv installed python3.10.6.
Solution:
sudo apt install libssl-dev