前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >解决python报错:ModuleNotFoundError: No module named '_sysconfigdata_x86_64_conda_linux_gnu'

解决python报错:ModuleNotFoundError: No module named '_sysconfigdata_x86_64_conda_linux_gnu'

作者头像
DechinPhy
发布2021-10-28 15:40:14
2.5K0
发布2021-10-28 15:40:14
举报
文章被收录于专栏:Dechin的专栏

技术背景

在上一篇博客中执行过conda的更新以及用conda安装了gxx_linux-64之后,再执行pip的一些指令时,就会给出如下所示的报错:

代码语言:javascript
复制
$ python3 -m pip list
Traceback (most recent call last):
  File "/home/dechin/anaconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/dechin/anaconda3/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/__main__.py", line 29, in <module>
    from pip._internal.cli.main import main as _main
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 9, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
    from pip._internal.cli.parser import ConfigOptionParser
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
    from pip._internal.configuration import Configuration, ConfigurationError
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/_internal/configuration.py", line 27, in <module>
    from pip._internal.utils.misc import ensure_dir, enum
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 42, in <module>
    from pip._internal.locations import get_major_minor_version, site_packages, user_site
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
    from . import _distutils, _sysconfig
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/_distutils.py", line 18, in <module>
    from .base import get_major_minor_version
  File "/home/dechin/anaconda3/lib/python3.8/site-packages/pip/_internal/locations/base.py", line 14, in <module>
    site_packages = sysconfig.get_path("purelib")  # type: typing.Optional[str]
  File "/home/dechin/anaconda3/lib/python3.8/sysconfig.py", line 521, in get_path
    return get_paths(scheme, vars, expand)[name]
  File "/home/dechin/anaconda3/lib/python3.8/sysconfig.py", line 511, in get_paths
    return _expand_vars(scheme, vars)
  File "/home/dechin/anaconda3/lib/python3.8/sysconfig.py", line 172, in _expand_vars
    _extend_dict(vars, get_config_vars())
  File "/home/dechin/anaconda3/lib/python3.8/sysconfig.py", line 559, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/home/dechin/anaconda3/lib/python3.8/sysconfig.py", line 430, in _init_posix
    _temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
ModuleNotFoundError: No module named '_sysconfigdata_x86_64_conda_linux_gnu'

问题定位与解决

经过一圈的检索,最后对问题的出现原因定位为:在某一个版本的python中丢失了一个备份文件,通常在同一个版本的python下会有两个相同的_sysconfigdata_x86_64_conda_cos6_linux_gnu.py文件和_sysconfigdata_x86_64_conda_linux_gnu.py文件。而在某些程序的运行过程中会依赖于其中的一个,因此我们需要做的就是检索系统中是否存在有这两个文件:

代码语言:javascript
复制
$ sudo find ~ -name _sysconfigdata_x86_64*
[sudo] dechin 的密码: 
/home/dechin/anaconda3/lib/python3.8/_sysconfigdata_x86_64_apple_darwin13_4_0.py
/home/dechin/anaconda3/lib/python3.8/__pycache__/_sysconfigdata_x86_64_apple_darwin13_4_0.cpython-38.pyc
/home/dechin/anaconda3/lib/python3.8/_sysconfigdata_x86_64_conda_cos6_linux_gnu.py

这里我们发现当前使用的python3.8路径下只有一个_sysconfigdata_x86_64_conda_cos6_linux_gnu.py文件而没有_sysconfigdata_x86_64_conda_linux_gnu.py文件,因此我们只需要讲该文件拷贝一份即可:

代码语言:javascript
复制
$ cp /home/dechin/anaconda3/lib/python3.8/_sysconfigdata_x86_64_conda_cos6_linux_gnu.py /home/dechin/anaconda3/lib/python3.8/_sysconfigdata_x86_64_conda_linux_gnu.py

此时再重新执行pip的指令:

代码语言:javascript
复制
$ python3 -m pip listPackage                            Version
---------------------------------- -----------------
absl-py                            0.13.0
adamod                             0.0.3
affinity                           0.1.0
alabaster                          0.7.12
anaconda-client                    1.8.0
anaconda-navigator                 1.10.0
anaconda-project                   0.10.1
anyio                              2.2.0
...

成功运行,问题解决。

总结概要

在近期conda的版本更新中,有可能会删除路径下的_sysconfigdata_x86_64_conda_linux_gnu模块相关备份文件,而在其他的一些软件的运行过程中有可能依赖于这个备份文件,这就会导致运行过程报错模块无法找到的问题。最终我们通过重新复制备份这个文件解决了该问题。

版权声明

本文首发链接为:https://cloud.tencent.com/developer/article/1894349

作者ID:DechinPhy

更多原著文章请参考:https://www.cnblogs.com/dechinphy/

打赏专用链接:https://www.cnblogs.com/dechinphy/gallery/image/379634.html

腾讯云专栏同步:https://cloud.tencent.com/developer/column/91958

参考链接

  1. https://shixiangwang.github.io/blog/conda-error-sysconfigdata-not-found/
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-10-27 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 技术背景
  • 问题定位与解决
  • 总结概要
  • 版权声明
  • 参考链接
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档