当我尝试从命令提示符访问python时,Windows 10上的致命python错误

发布于 2025-01-20 13:07:37 字数 1485 浏览 1 评论 0 原文

我在上一个线程中做了 这些答案中的所有内容 并没有任何改变。即使卸载Python也没有改善这种情况。一切都工作正常,但突然就停止工作了。

    Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = 'C:\\iverilog\\gtkwave\\bin\\python.exe'
  sys.base_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.base_exec_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.executable = 'C:\\iverilog\\gtkwave\\bin\\python.exe'
  sys.prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.exec_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.path = [
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python38.zip',
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.8',
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.8',
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000029e8 (most recent call first):
<no Python frame>

I did everything from these answers on a previous thread and nothing changed. Even uninstalling Python did not improve the situation. Everything was working fine but all of a sudden it stopped working.

    Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = 'python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = 'C:\\iverilog\\gtkwave\\bin\\python.exe'
  sys.base_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.base_exec_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.executable = 'C:\\iverilog\\gtkwave\\bin\\python.exe'
  sys.prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.exec_prefix = 'D:\\a\\_temp\\msys\\msys64\\mingw64'
  sys.path = [
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python38.zip',
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.8',
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\python3.8',
    'D:\\a\\_temp\\msys\\msys64\\mingw64\\lib\\lib-dynload',
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x000029e8 (most recent call first):
<no Python frame>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绅士风度i 2025-01-27 13:07:37

我只是遇到了同样的问题。

回顾过去,错误很明显: modulenotfoundError:没有名为“编码”的模块意味着Python无法找到编码模块,这是Python内置模块之一。我查看了我的文件系统,发现编码模块是在 c:\ msys64 \ mingw64 \ lib \ lib \ python3.8 \ condodings 上找到的。这意味着Python找不到该文件夹​​!

我的简单解决方案是将 c:\ msys64 \ mingw64 \ lib \ python3.8 添加到 pythonpath 环境变量。在Windows上,您可以从设置Pythonpath = C:\ MSYS64 \ Mingw64 \ lib \ python3.8 \ 。

这种感觉就像是一个黑客,因为作为基本的Python模块,它应该自动找到,但却没有。但是,在这一点上,我没有其他与Python有关的问题,所以我认为这确实可以解决问题。

I've just had the same problem.

Looking back, the error is fairly clear: ModuleNotFoundError: No module named 'encodings' means Python is not able to find the encodings module, one of Python built-in modules. I had a look at my filesystem and found out that the encodings module is found at C:\msys64\mingw64\lib\python3.8\encodings. This meant that Python could not find that folder!

My simple solution was to add C:\msys64\mingw64\lib\python3.8 to the PYTHONPATH environment variable. On Windows you can either set it from the Windows settings UI - the permanent way - or set it temporarily from the command line, using this command: set PYTHONPATH=C:\msys64\mingw64\lib\python3.8\.

This kind of feels like a hack since, as a basic Python module, it should be found automatically and yet doesn't. However, at this point, I've had no other Python-related problems so I figure it really does the trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文