I want to use json parser in my python script. When I import json module there is an ImportError:
root@msc-nr-imx6x:~# python3
Python 3.5.2 (default, Aug 9 2017, 22:59:34)
[GCC 6.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'json'
>>>
I supposed that in python3 json is built-in. Python is running on - arm imx6, yocto 2.2, python 3.5.2
So how can I install json module?
Thank you
Edit - add output of test.py script:
try:
import json
except ImportError:
import simplejson as json
output:
root@msc-nr-imx6x:~# python3 test.py
Traceback (most recent call last):
File "test.py", line 2, in <module>
import json
ImportError: No module named 'json'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 4, in <module>
import simplejson as json
ImportError: No module named 'simplejson'
Yocto creates embedded systems: this is why python does not automatically come with all of the modules it usually does. Whoever created the image you're using had the option of including all standard modules but did not do that.
If you are building your own image you can include more python packages in your image install, either python3-json
for just what you need or something like python3-modules
to get all the common ones: see meta/recipes-devtools/python/python3/python3-manifest.json for more details on the split.
EDIT: Actually, you are using an old Yocto version so probably want to look at meta/recipes-devtools/python/python-3.5-manifest.inc for the details