ModuleNotFoundError: No module named 'checker'
0pLuS0 opened this issue · 20 comments
Hi,
I'm running Slackware 14.2 x64 and I have python3 3.6.6 installed, and when I run the script I get this at the terminal;
Traceback (most recent call last):
File "extract_android_ota_payload.py", line 12, in
import update_payload
File "/home/foo/Downloads/update_payload/init.py", line 9, in
from checker import CHECKS_TO_DISABLE
ModuleNotFoundError: No module named 'checker'
I've noticed the command showing running it on a zip so I tried it that way too;
python3 extract_android_ota_payload.py CARBON-CR-6.1-NOCT-RELEASE-mata-20180811-0405.zip /home/foo/Downloads/CR
But then I also extracted the zip and ran the command on the payload.bin, I extracted the rom and placed the contents of extract_android_ota_payload in the same directory as below;
META-INF
README.md
care_map.txt
compatibility.zip
extract_android_ota_payload.py
payload.bin
payload_properties.txt
update_payload
But I get the same message;
Traceback (most recent call last):
File "extract_android_ota_payload.py", line 12, in
import update_payload
File "/home/foo/Downloads/CARBON-CR-6.1-NOCT-RELEASE-mata-20180811-0405/update_payload/init.py", line 9, in
from checker import CHECKS_TO_DISABLE
ModuleNotFoundError: No module named 'checker'
Thanks
Do you have access to / can you try with python 2.x ?
Sorry I forgot to mention, I tried 2 & 3 and it's all the same...
Thanks
Same here. Using windows and Python 3.6.
Ok I just pulled the latest from GIT, still having problem with python 2 & 3
~ pts/0 foo ~/Build >cd /home/foo/Build/extract_android_ota_payload
~ pts/0 foo ~/Build/extract_android_ota_payload >ls
README.md extract_android_ota_payload.py payload.bin update_metadata_pb2.py
~ pts/0 foo ~/Build/extract_android_ota_payload >python3 extract_android_ota_payload.py payload.bin /tmp
Traceback (most recent call last):
File "extract_android_ota_payload.py", line 13, in
import update_metadata_pb2
File "/home/foo/Build/extract_android_ota_payload/update_metadata_pb2.py", line 4, in
from google.protobuf import descriptor as _descriptor
ModuleNotFoundError: No module named 'google'
~ pts/0 foo ~/Build/extract_android_ota_payload >python extract_android_ota_payload.py payload.bin /tmp
Traceback (most recent call last):
File "extract_android_ota_payload.py", line 13, in
import update_metadata_pb2
File "/home/foo/Build/extract_android_ota_payload/update_metadata_pb2.py", line 4, in
from google.protobuf import descriptor as _descriptor
ImportError: No module named google.protobuf
I think you need to install python-protobuf. Not sure what is the exact package name with Slackware...
@cyxx It's just protobuf or protobuf3 like it's normally called;
http://slackbuilds.org/repository/14.2/misc/protobuf3/
I hope I can use protobuf3 for python3?
Do you know anything about this Google Test, Google's C++ test framework?
Google on my phone is about all I can stomach, but I certainly don't want any Google installed into my box, that's a big no no for me.
Does protobuf3 just use Google Test as a Compile Dependency?
I have no idea why googletest is listed on that page.
Can we close this ? The original issue should be fixed now.
I can update the README protobuf is a dependency, though.
Sorry I should of just read the slack-desc
which is the package description when you install, telling you what it is;
protobuf3 (Google's data interchange format)
Protocol Buffers are Google's language-neutral, platform-neutral,
extensible mechanism for serializing structured data.
So yeah lots of Google here...
Ok I installed protobuf3-3.5.2 and still more problems;
python3 extract_android_ota_payload.py payload.bin /tmp
Traceback (most recent call last):
File "extract_android_ota_payload.py", line 13, in
import update_metadata_pb2
File "/home/foo/Build/extract_android_ota_payload/update_metadata_pb2.py", line 4, in
from google.protobuf import descriptor as _descriptor
File "/usr/lib64/python3.6/site-packages/google/protobuf/descriptor.py", line 37, in
import six
ModuleNotFoundError: No module named 'six'
Looks like protobuf has a dependency on python-six.
@cyxx Hi, ok, I'll look into that...
By the way, when we get done, hopefully figuring this out, hehe, it would be great if you made up a Dependency List
here for others to read, because from what I'm seeing, these are not commonly installed in distros. These are extras someone needs to install, and without a list, no one is going to know the Dependencies of this... :)
You are right, I will update the README with the protobuf dependency.
Dependencies of protobuf should probably be handled by the distro package manager itself, though.
Thanks,
@cyxx Six installed, at first I installed by mistake for python2 LOL...
New problem now...
python3 extract_android_ota_payload.py payload.bin /tmp
Traceback (most recent call last):
File "extract_android_ota_payload.py", line 13, in
import update_metadata_pb2
File "/home/foo/Build/extract_android_ota_payload/update_metadata_pb2.py", line 216, in
has_default_value=False, default_value=unicode("", "utf-8"),
NameError: name 'unicode' is not defined
It seems the protoc compiler used to generate the update_metadata_pb2 expects python 2.x for the runtime. I added a check to error out on any other version for now.
I will look at how to support python 3.x or generate code for protobuf3 (different issue).
@cyxx it's working for python2! :)
~/Build/extract_android_ota_payload >python extract_android_ota_payload.py payload.bin /tmp
Extracting 'boot.img'
Extracting 'system.img'
Extracting 'vendor.img'
And /tmp shows the images!
So it looks like the two things needed outside a typical distro are;
protobuf
python-six
THANKS
@cyxx hi, is there anyway to write the code, so that extract_android_ota_payload can be self-contained without the need to install any dependencies?
I know these are only a couple of things, compiling and packaging them isn't the problem, I'd rather wish I could simply take the contents of the pkg for both protobuf & six and place them under the extract_android_ota_payload directory and let it look for everything it needs in it's own path and work.
Or maybe you can simply supply protobuf & six to it, and make this work? If you could that would really be great!
Thanks
I understand the need but this might be a bit out of scope.
Have you checked other tools, such as pyinstaller ?
Well I gave it a shot, so not sure if an issue with pyinstaller, or not liking the code/source of extract_android_ota_payload?
When I then tried running it I get this;
./extract_android_ota_payload payload.bin
Traceback (most recent call last):
File "extract_android_ota_payload.py", line 17, in
File "/usr/lib64/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.dict)
File "update_metadata_pb2.py", line 4, in
File "/usr/lib64/python2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.dict)
File "site-packages/google/protobuf/init.py", line 39, in
ImportError: No module named pkgutil
Failed to execute script extract_android_ota_payload
This is odd, so not sure what's going on, because pkgutil is in python2 and python3...
To do this, I just ran; pyinstaller extract_android_ota_payload.py
I ran the command in the dist
directory it creates, which is the completed app...
Hey look, I understand this is not your concern, but if you're into this, maybe you can play with pyinstaller and make extract_android_ota_payload into a self contained app.
It's just fun Geek stuff to play around with, if you don't mind? Me I'm lost and have no idea with this now... LOL
By the way I found this other source and I used the two python files and ran pyinstaller on them and I was able to make this work.
Maybe you'll find this source of interest;
https://gist.github.com/ius/42bd02a5df2226633a342ab7a9c60f15
Thanks
I have no experience with pyinstaller myself but I will try to check this.
Thanks a lot for sharing the gist. I was not aware of it, I wrote the tool as I did not find anything, I guess I did not look hard enough !