Python 2.7 &引用;pip安装json";在Ubuntu上失败

Python 2.7 &引用;pip安装json";在Ubuntu上失败,python-2.7,pip,ubuntu-16.04,Python 2.7,Pip,Ubuntu 16.04,无法安装json模块。 据我所知,我不应该用sudo。怎么了 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 executi

无法安装json模块。 据我所知,我不应该用sudo。怎么了

 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/
pip安装json
当前用户不拥有目录“/home/snow/.cache/pip/http”或其父目录,缓存已被禁用。请检查该目录的权限和所有者。如果使用sudo执行pip,您可能需要sudo的-H标志。
当前用户不拥有目录“/home/snow/.cache/pip”或其父目录,并且已禁用缓存控制盘。检查该目录的权限和所有者。如果使用sudo执行pip,您可能需要sudo的-H标志。
收集json
下载json-99.0.tar.gz
从命令python setup.py egg_info完成输出:
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/tmp/pip build YkvqVh/json/setup.py”,第2行,在
raise RUNTIMERROR(“不能从pypi下载包“json”)
RuntimeError:不能从pypi下载包“json”
----------------------------------------
命令“python setup.py egg_info”在/tmp/pip build YkvqVh/json中失败,错误代码为1/

是一个内置模块,您不需要使用
pip
安装它虽然
json
确实是一个内置模块,但我还发现在安装了
python minimal
的Ubuntu系统上,您确实有
python
,但您不能
导入json
。然后我了解到您将尝试使用pip安装模块

如果你有
pythonmiminal
,你会得到一个版本的python,它的模块比你通常自己编译python时少,你会缺少的模块之一就是
json
模块。解决方案是安装一个名为
libpython2.7-stdlib
的附加包,以安装所有“默认”python库

sudo apt install libpython2.7-stdlib

然后你可以用python做
导入json
,它就可以工作了

关于
raiseruntimeerror(“包'json'不能从pypi下载”)
有什么不清楚的地方吗?如果是这样的话,应该说“包是不必要的”。如果有人告诉我需要安装一个软件包,而安装程序说我无法从X下载,那么合理的假设是我需要从其他地方下载它。但是在哪里呢?它是一个内置模块,不能用
pip
安装。如果你像上面的用户一样使用ubuntu,可能你有python2,但没有json;看到我的答案了。非常感谢你的洞察力@MichielB