由于 json Python 模块冲突,chrome-gnome-shell 失败

由于 json Python 模块冲突,chrome-gnome-shell 失败

最近,Gnome Shell 集成插件在 Firefox 和 Chrome 上开始出现故障。

经过一番调查后,我更新了requests模块,pip3但收到了另一个错误:

  File "/usr/bin/chrome-gnome-shell", line 220, in on_input
request = json.loads(text)
[10391] Exception: module 'json' has no attribute 'loads'

我做了一些进一步的调查,发现这个 GitHub 问题关于冲突的json模块,并继续查找json.py我的文件系统上是否有任何指定的文件。我删除了所有发现的内容,但错误仍然存​​在。

然后我打开一个交互式Python shell来检查,仍然没有运气:

$ python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
>>> import json
>>> json.loads
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'json' has no attribute 'loads'
>>> json.__path__
_NamespacePath(['/usr/local/lib/python3.6/dist-packages/json'])
>>> json.__file__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'json' has no attribute '__file__'

我无法猜测我的问题是什么。你有什么主意吗?

谢谢。


一些附加信息:

$ lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.3 LTS
Release:    18.04
Codename:   bionic
$ uname -a
Linux capt-XPS-13-9370 4.15.0-1050-oem #57-Ubuntu SMP Wed Aug 7 10:34:10 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

$ find / -name "json" 2>/dev/null
/home/capt/.config/yarn/global/node_modules/@angular-devkit/core/src/json
/home/capt/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47/info/json
/home/capt/.cache/yarn/v2/npm-fs-extra-4.0.3-0d852122e5bc5beb453fb028e9c0c9bf36340c94/lib/json
/home/capt/.cache/yarn/v2/npm-fs-extra-6.0.1-8abc128f7946e310135ddc93b98bddb410e7a34b/lib/json
/home/capt/.cache/yarn/v2/npm-istanbul-reports-2.0.1-fb8d6ea850701a3984350b977a969e9a556116a7/lib/json
/home/capt/.cache/yarn/v2/npm-fs-extra-7.0.1-4f189c44aa123b895f722804f55ea23eadc348e9/lib/json
/home/capt/.cache/yarn/v2/npm-@angular-devkit/core-0.7.5-49f7854ccadf3ddda8d0ea4359543a1cbdc6854d/src/json
/home/capt/.cache/yarn/v2/npm-@angular-devkit/core-7.3.2-67ac2cfcbe47f1e457929c19ab1b04c9e061b2e2/src/json
/home/capt/.cache/yarn/v2/npm-core-js-2.5.7-f972608ff0cead68b841a16a932d0b183791814e/fn/json
/home/capt/.cache/yarn/v2/npm-core-js-2.5.7-f972608ff0cead68b841a16a932d0b183791814e/library/fn/json
/home/capt/.cache/yarn/v2/npm-core-js-2.3.0-fab83fbb0b2d8dc85fa636c4b9d34c75420c6d65/fn/json
/home/capt/.cache/yarn/v2/npm-core-js-2.3.0-fab83fbb0b2d8dc85fa636c4b9d34c75420c6d65/library/fn/json
/home/capt/.cache/yarn/v2/npm-babel-runtime-6.26.0-965c7058668e82b55d7bfe04ff2337bc8b5647fe/core-js/json
/home/capt/.cache/yarn/v2/npm-libphonenumber-0.0.10-e78bbf6601989cd09fa43504764688d41794148c/lib/closure/goog/json
/home/capt/.npm_modules/lib/node_modules/serverless/node_modules/core-js/fn/json
/home/capt/.npm_modules/lib/node_modules/serverless/node_modules/core-js/library/fn/json
/home/capt/.npm_modules/lib/node_modules/serverless/node_modules/fs-extra/lib/json
/home/capt/.npm_modules/lib/node_modules/serverless/node_modules/babel-runtime/core-js/json
/home/capt/.npm_modules/lib/node_modules/serverless/node_modules/aws-sdk/lib/json
/home/capt/.gradle/caches/modules-2/files-2.1/org.json/json
/home/capt/.gradle/caches/modules-2/metadata-2.58/descriptors/org.json/json
/home/capt/IdeaProjects/prj-front/node_modules/libphonenumber/lib/closure/goog/json
/home/capt/IdeaProjects/prj-front/node_modules/jszip/node_modules/core-js/fn/json
/home/capt/IdeaProjects/prj-front/node_modules/jszip/node_modules/core-js/library/fn/json
/home/capt/IdeaProjects/prj-front/node_modules/istanbul-reports/lib/json
/home/capt/IdeaProjects/prj-front/node_modules/core-js/fn/json
/home/capt/IdeaProjects/prj-front/node_modules/core-js/library/fn/json
/home/capt/IdeaProjects/prj-front/node_modules/fs-extra/lib/json
/home/capt/IdeaProjects/prj-front/node_modules/babel-runtime/core-js/json
/home/capt/IdeaProjects/prj-front/node_modules/@angular-devkit/core/src/json
/home/capt/IdeaProjects/prj-front/node_modules/find-yarn-workspace-root/node_modules/fs-extra/lib/json
/home/capt/IdeaProjects/PrjApi/build/resources/test/json
/home/capt/IdeaProjects/PrjApi/build/classes/java/main/com/prj/Prjapi/converter/json
/home/capt/IdeaProjects/PrjApi/src/main/java/com/prj/Prjapi/converter/json
/home/capt/IdeaProjects/PrjApi/src/test/resources/json
/usr/share/iso-codes/json
/usr/local/lib/python3.6/dist-packages/json
/usr/lib/python2.7/json
/usr/lib/x86_64-linux-gnu/ruby/2.5.0/json
/usr/lib/python3.6/json
/usr/lib/ruby/2.5.0/psych/json
/usr/lib/ruby/2.5.0/json
/snap/aws-cli/146/usr/lib/python3.6/json
/snap/core18/1074/usr/lib/python3.6/json
/snap/core18/1098/usr/lib/python3.6/json
/snap/gnome-3-28-1804/67/usr/lib/python3.6/json
/snap/gnome-3-28-1804/67/usr/share/iso-codes/json
/snap/gnome-3-28-1804/71/usr/lib/python3.6/json
/snap/gnome-3-28-1804/71/usr/share/iso-codes/json
/snap/core/7396/usr/lib/python3.5/json
/snap/core/7270/usr/lib/python3.5/json
/snap/intellij-idea-ultimate/165/plugins/spy-js/server/node_modules/archiver/lib/modules/json
/snap/intellij-idea-ultimate/165/plugins/textmate/lib/bundles/json
/snap/intellij-idea-ultimate/159/plugins/spy-js/server/node_modules/archiver/lib/modules/json
/snap/intellij-idea-ultimate/159/plugins/textmate/lib/bundles/json
/var/lib/gems/2.5.0/gems/activesupport-5.0.7/lib/active_support/json
/var/lib/gems/2.5.0/gems/activesupport-5.0.6/lib/active_support/json

答案1

您的目录json中可能有一个包含可能是罪魁祸首的目录。尝试删除它,看看是否有帮助。sys.path__init__.py

相关内容