[python-2.7] "pip install json" fails on Ubuntu

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 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/

This question is related to python-2.7 pip ubuntu-16.04

The answer is


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


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!


Examples related to python-2.7

Numpy, multiply array with scalar Not able to install Python packages [SSL: TLSV1_ALERT_PROTOCOL_VERSION] How to create a new text file using Python Could not find a version that satisfies the requirement tensorflow Python: Pandas pd.read_excel giving ImportError: Install xlrd >= 0.9.0 for Excel support Display/Print one column from a DataFrame of Series in Pandas How to calculate 1st and 3rd quartiles? How can I read pdf in python? How to completely uninstall python 2.7.13 on Ubuntu 16.04 Check key exist in python dict

Examples related to pip

How to fix error "ERROR: Command errored out with exit status 1: python." when trying to install django-heroku using pip "E: Unable to locate package python-pip" on Ubuntu 18.04 How to Install pip for python 3.7 on Ubuntu 18? What is the meaning of "Failed building wheel for X" in pip install? Could not install packages due to an EnvironmentError: [Errno 13] How do I install Python packages in Google's Colab? Conda version pip install -r requirements.txt --target ./lib pip: no module named _internal AttributeError: Module Pip has no attribute 'main' Error after upgrading pip: cannot import name 'main'

Examples related to ubuntu-16.04

Yarn: How to upgrade yarn version using terminal? pull access denied repository does not exist or may require docker login Failed to start mongod.service: Unit mongod.service not found How to completely uninstall python 2.7.13 on Ubuntu 16.04 Anaconda-Navigator - Ubuntu16.04 Default password of mysql in ubuntu server 16.04 Unable to set default python version to python3 in ubuntu "pip install json" fails on Ubuntu Unable to start the mysql server in ubuntu How to install php-curl in Ubuntu 16.04