无法安装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/发布于 2017-01-04 22:38:49
json是一个内置模块,你不需要和pip一起安装它。
发布于 2018-08-24 17:05:42
虽然json确实是一个内置模块,但我也发现在安装了python-minimal的Ubuntu系统上,您确实安装了python,但您不能使用import json。然后我知道你会试着用pip安装模块!
如果您有python-minimal,您将得到一个比通常自己编译python时更少模块的python版本,并且您将缺少的一个模块是json模块。解决方案是安装一个名为libpython2.7-stdlib的附加包,以安装所有“默认”python库。
sudo apt install libpython2.7-stdlib然后你可以用python做import json,它就可以工作了!
https://stackoverflow.com/questions/41466431
复制相似问题