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 main
File "/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 autocomplete
File "/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_parser
File "/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_pip
File "/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_spinner
File "/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_indentation
File "/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_dir
File "/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_version
File "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/site-packages/pip/_internal/locations/__init__.py", line 14, in <module>
from . import _sysconfig
File "/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_framework
File "/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_path
return get_paths(scheme, vars, expand)[name]
File "/home/jayce/anaconda3/envs/nlgeval/lib/python3.8/sysconfig.py", line 511, in get_paths
return _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.结果预览🤔
直接重新运行安装命令即可
渣男!都看到这里了,还不赶紧点赞
,评论
,收藏
走一波?