首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >"pip install json“在Ubuntu上失败

问"pip install json“在Ubuntu上失败
EN

Stack Overflow用户
提问于 2017-01-04 22:37:28
回答 2查看 133K关注 0票数 40

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

代码语言:javascript
复制
 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/
EN

回答 2

Stack Overflow用户

发布于 2017-01-04 22:38:49

json是一个内置模块,你不需要和pip一起安装它。

票数 94
EN

Stack Overflow用户

发布于 2018-08-24 17:05:42

虽然json确实是一个内置模块,但我也发现在安装了python-minimal的Ubuntu系统上,您确实安装了python,但您不能使用import json。然后我知道你会试着用pip安装模块!

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

代码语言:javascript
复制
sudo apt install libpython2.7-stdlib

然后你可以用python做import json,它就可以工作了!

票数 12
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41466431

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档