为了账号安全,请及时绑定邮箱和手机立即绑定

ImportError:没有名为'encodings'的模块

ImportError:没有名为'encodings'的模块

慕的地8271018 2019-09-03 16:16:51
我最近重新安装了ubuntu并升级到16.04并且无法使用python:$ python manage.py runserverCould not find platform independent libraries <prefix>Could not find platform dependent libraries <exec_prefix>Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]Fatal Python error: Py_Initialize: Unable to get the locale encodingImportError: No module named 'encodings'Aborted此时,python本身不起作用$ pythonCould not find platform independent libraries <prefix>Could not find platform dependent libraries <exec_prefix>Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]Fatal Python error: Py_Initialize: Unable to get the locale encodingImportError: No module named 'encodings'Aborted即使这个建议不再有效:unset PYTHONHOMEunset PYTHONPATH每一次我都以一种方式修复它,它又回来了。几个答案有助于暂时解决它,但不是很好。我已经多次重新安装了python和python3。我能从这里做什么?谢谢
查看完整描述

3 回答

?
蝴蝶不菲

TA贡献1810条经验 获得超4个赞

对于Windows10用户。

我在Windows10上使用python3.4。我安装了python3.5。我找不到PYTHONPATH,PYTHONHOME env变量。如果我在CMD控制台中命令python,它继续使用python3.4。我删除了python3.4。每当我在CMD控制台中命令python时,它就会开始显示如下错误。


Fatal Python error: Py_Initialize: Unable to get the locale encoding

ImportError: No module named 'encodings'

我搜索了解我的问题。解决方案很简单。安装python3.5时,可以在“高级选项”中自定义安装并选中“ 将Python添加到环境变量”。


我只是离开这里,以便有人有类似的问题访问这里,这样他们就不会浪费宝贵的时间去弄清楚。


查看完整回答
反对 回复 2019-09-03
?
烙印99

TA贡献1829条经验 获得超13个赞

我在Windows7下遇到了同样的问题。错误消息如下所示:


Fatal Python error: Py_Initialize: unable to load the file system codec

ModuleNotFoundError: No module named 'encodings'


Current thread 0x000011f4 (most recent call first):

我已经安装了python 2.7(现在已卸载),并在安装python 3.6时检查了“将Python添加到高级选项中的环境变量”。结果是环境变量“ PYTHONHOME ”和“ PYTHONPATH ”仍然是python2.7。


最后我通过将“ PYTHONHOME ” 修改为python3.6安装路径并删除变量“ PYTHONPATH ” 来解决它。


查看完整回答
反对 回复 2019-09-03
  • 3 回答
  • 0 关注
  • 10485 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信