概述
在Linux 系统下安装有多个python版本时,运行python报如下错误。
[vfy_xp@login_a09 ~]$ python
Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/site.py", line 541, in <module>
main()
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/site.py", line 522, in main
known_paths = addusersitepackages(known_paths)
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/site.py", line 282, in addusersitepackages
user_site = getusersitepackages()
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/site.py", line 258, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/site.py", line 248, in getuserbase
USER_BASE = get_config_var('userbase')
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/sysconfig.py", line 659, in get_config_var
return get_config_vars().get(name)
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/sysconfig.py", line 633, in get_config_vars
conda_customize_compiler(_CONFIG_VARS)
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/sysconfig.py", line 528, in conda_customize_compiler
from _osx_support import _find_executable
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/_osx_support.py", line 4, in <module>
import re
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/re.py", line 123, in <module>
import sre_compile
File "/g1/app/apps/python/3.6.3/gnu/lib/python3.6/sre_compile.py", line 17, in <module>
assert _sre.MAGIC == MAGIC, "SRE module mismatch"
AssertionError: SRE module mismatch
在 .bashrc 设置了module load apps/python/3.6.3/gnu,报存后 source .bashrc ,但运行python 时仍然报同样错误。 解决方案是
vi .bash_profile
在文件末尾添加
export PYTHON_HOME=/g1/app/apps/python/3.6.3/gnu/
export PATH=$PYTHON_HOME/bin:$PATH
报存后 source .bash_profile
重新运行python 问题解决。
最后
以上就是俭朴可乐为你收集整理的Linux 下报AssertionError: SRE module mismatch的全部内容,希望文章能够帮你解决Linux 下报AssertionError: SRE module mismatch所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复