您的位置:首页 > 科技 > IT业 > ModuleNotFoundError: No module named ‘_sysconfigdata_x86_64_conda_linux_gnu‘

ModuleNotFoundError: No module named ‘_sysconfigdata_x86_64_conda_linux_gnu‘

2024/11/19 20:15:35 来源:https://blog.csdn.net/qq_15969343/article/details/140071732  浏览:    关键词:ModuleNotFoundError: No module named ‘_sysconfigdata_x86_64_conda_linux_gnu‘

ModuleNotFoundError: No module named '_sysconfigdata_x86_64_conda_linux_gnu'

  • 1.软件环境⚙️
  • 2.问题描述🔍
  • 3.解决方法🐡
  • 4.结果预览🤔

1.软件环境⚙️

Ubuntu 20.04
Python 3.7.0

2.问题描述🔍

今天发现更新conda之后,使用pip无论安装什么包都会报错:

ModuleNotFoundError: No module named ‘_sysconfigdata_x86_64_conda_linux_gnu’

具体报错如下:

(nlgeval) jayce@DESKTOP-BOJNA8J:~$ pip install tensorflow-gpu==
Traceback (most recent call last):File "/home/jayce/anaconda3/envs/nlgeval/bin/pip", line 7, in <module>from pip._internal.cli.main import mainFile "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 10, in <module>from pip._internal.cli.autocompletion import autocompleteFile "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>from pip._internal.cli.main_parser import create_main_parserFile "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 9, in <module>from pip._internal.build_env import get_runnable_pipFile "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/build_env.py", line 19, in <module>from pip._internal.cli.spinners import open_spinnerFile "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/cli/spinners.py", line 9, in <module>from pip._internal.utils.logging import get_indentationFile "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/utils/logging.py", line 29, in <module>from pip._internal.utils.misc import ensure_dirFile "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/utils/misc.py", line 44, in <module>from pip._internal.locations import get_major_minor_versionFile "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 14, in <module>from . import _sysconfigFile "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/locations/_sysconfig.py", line 11, in <module>from .base import change_root, get_major_minor_version, is_osx_frameworkFile "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/locations/base.py", line 16, in <module>site_packages: str = sysconfig.get_path("purelib")File "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/sysconfig.py", line 521, in get_pathreturn get_paths(scheme, vars, expand)[name]File "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/sysconfig.py", line 511, in get_pathsreturn _expand_vars(scheme, vars)File "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/sysconfig.py", line 172, in _expand_vars_extend_dict(vars, get_config_vars())File "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/sysconfig.py", line 559, in get_config_vars_init_posix(_CONFIG_VARS)File "/home/jayce/anaconda3/envs/nlgeval/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'

在这里插入图片描述

那这个时候又该怎么办呢?
在这里插入图片描述

3.解决方法🐡

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

sudo find ~ -name _sysconfigdata_x86_64*

可以看到当前环境中只有_sysconfigdata_x86_64_conda_cos6_linux_gnu.py而没有_sysconfigdata_x86_64_conda_linux_gnu.py
在这里插入图片描述
因此,我们将_sysconfigdata_x86_64_conda_cos6_linux_gnu.py重新拷贝一份并重命名为_sysconfigdata_x86_64_conda_linux_gnu.py即可:

cp /home/jayce/anaconda3/envs/nlgeval/lib/python3.8/_sysconfigdata_x86_64_conda_cos6_linux_gnu.py /home/jayce/anaconda3/envs/nlgeval/lib/python3.8/_sysconfigdata_x86_64_conda_linux_gnu.py

4.结果预览🤔

直接重新运行安装命令即可


渣男!都看到这里了,还不赶紧点赞评论收藏走一波?
在这里插入图片描述

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com