“pip install json” fails on Ubuntu

前端 未结 2 1288
情歌与酒
情歌与酒 2020-12-16 09:51

Cannot install the json module. As far as I know I shouldn\'t use sudo. what\'s the matter?

 pip install json
The directory \'/home/snow/.cache/pip/http\' or         


        
相关标签:
2条回答
  • 2020-12-16 10:11

    json is a built-in module, you don't need to install it with pip.

    0 讨论(0)
  • 2020-12-16 10:11

    While it's true that json is a built-in module, I also found that on an Ubuntu system with python-minimal installed, you DO have python but you can't do import json. And then I understand that you would try to install the module using pip!

    If you have python-minimal you'll get a version of python with less modules than when you'd typically compile python yourself, and one of the modules you'll be missing is the json module. The solution is to install an additional package, called libpython2.7-stdlib, to install all 'default' python libraries.

    sudo apt install libpython2.7-stdlib
    

    And then you can do import json in python and it would work!

    0 讨论(0)
提交回复
热议问题