“Pip Install JSON” Faalt op Ubuntu

kan de JSON-module niet installeren.
Voor zover ik weet, zou ik Sudo niet moeten gebruiken. Wat is er aan de hand?

pip install json
The directory '/home/snow/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/snow/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting json
  Downloading json-99.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-YkvqVh/json/setup.py", line 2, in <module>
        raise RuntimeError("Package 'json' must not be downloaded from pypi")
    RuntimeError: Package 'json' must not be downloaded from pypi
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-YkvqVh/json/

Antwoord 1, Autoriteit 100%

jsonis een ingebouwde module , u hoeft het niet te installeren met pip.


Antwoord 2, Autoriteit 12%

Hoewel het waar is dat jsoneen ingebouwde module is, vond ik dat ook op een Ubuntu-systeem met python-minimalGeïnstalleerd, u heeft pythonMaar u kunt het niet doen import json. En dan begrijp ik dat u probeert de module met PIP!

te installeren

Als je python-minimalhebt, krijg je een versie van python met minder modules dan wanneer je normaal gesproken python zelf zou compileren, en een van de modules die je mist is de json-module. De oplossing is om een extra pakket te installeren, genaamd libpython2.7-stdlib, om alle ‘standaard’ python-bibliotheken te installeren.

sudo apt install libpython2.7-stdlib

En dan kun je import jsonin python doen en het zou werken!

Other episodes