Python 确实无法运行

huangapple go评论79阅读模式
英文:

Python literally just won't run

问题

因此,在调用Python时,我遇到了这个错误。路径配置如下:

Python路径配置:
  PYTHONHOME =(未设置)
  PYTHONPATH =(未设置)
  程序名称 = 'python'
  隔离 = 0
  环境 = 1
  用户站点 = 1
  安全路径 = 0
  导入站点 = 1
  在构建树中 = 0
  标准库目录 = 'C:\Users\iamco\AppData\Local\Programs\Python\Python311\Lib'
  sys._base_executable = 'C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311\\python.exe'
  sys.base_prefix = 'C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311'
  sys.base_exec_prefix = 'C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311'
  sys.platlibdir = 'DLLs'
  sys.executable = 'C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311\\python.exe'
  sys.prefix = 'C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311'
  sys.exec_prefix = 'C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311'
  sys.path = [
    'C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip',
    'C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311\\Lib',
    'C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311\\DLLs',
  ]
致命Python错误:init_fs_encoding:无法获取文件系统编码的Python编解码器
Python运行时状态:核心已初始化
回溯(最近调用的最后一次):
  File "C:\Users\iamco\AppData\Local\Programs\Python\Python311\Lib\encodings\__init__.py",第33行,在<module>中
  File "C:\Users\iamco\AppData\Local\Programs\Python\Python311\Lib\encodings\aliases.py",第552行,在<module>中
运行时错误:丢失sys.stdout

我在网上没有找到任何关于这个的信息。
我正在运行一些Python文件,然后出现了这个错误。
我尝试了多个文件,但我认为它是一个Python文件。

我尝试了多个文件
不仅仅是py3

英文:

So, I'm having this error when calling python

Python path configuration:
  PYTHONHOME = (not set)
  PYTHONPATH = (not set)
  program name = &#39;python&#39;
  isolated = 0
  environment = 1
  user site = 1
  safe_path = 0
  import site = 1
  is in build tree = 0
  stdlib dir = &#39;C:\Users\iamco\AppData\Local\Programs\Python\Python311\Lib&#39;
  sys._base_executable = &#39;C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311\\python.exe&#39;
  sys.base_prefix = &#39;C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311&#39;
  sys.base_exec_prefix = &#39;C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311&#39;
  sys.platlibdir = &#39;DLLs&#39;
  sys.executable = &#39;C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311\\python.exe&#39;
  sys.prefix = &#39;C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311&#39;
  sys.exec_prefix = &#39;C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311&#39;
  sys.path = [
    &#39;C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip&#39;,
    &#39;C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311\\Lib&#39;,
    &#39;C:\\Users\\iamco\\AppData\\Local\\Programs\\Python\\Python311\\DLLs&#39;,
  ]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
Traceback (most recent call last):
  File &quot;C:\Users\iamco\AppData\Local\Programs\Python\Python311\Lib\encodings\__init__.py&quot;, line 33, in &lt;module&gt;
  File &quot;C:\Users\iamco\AppData\Local\Programs\Python\Python311\Lib\encodings\aliases.py&quot;, line 552, in &lt;module&gt;
RuntimeError: lost sys.stdout

I haven't found anything online about this.
I was running some python files and I got this.
I tried multiple files, but I think it's a python file.

I tried multiple files
More than py3

答案1

得分: -3

可能的原因是Python环境配置不正确或系统文件完整性受损。不正确的Python路径配置或系统文件损坏可能导致sys.stdout对象丢失或初始化不正确。

以下是解决此问题的几种可能方法:

  1. 重新安装Python:尝试重新安装Python以更新或修复损坏的文件和设置。

  2. 检查环境:确保PYTHONHOME和PYTHONPATH环境变量已正确设置。它们必须指向正确的Python目录。

  3. 设置默认值:确保没有自定义代码或设置会更改或损坏标准输出(sys.stdout)。检查您的代码中是否滥用了sys.stdout对象。

英文:

It is likely that this error can be caused by an incorrect configuration of the Python environment or a violation of the integrity of system files. Incorrect Python path configuration or system file corruption can cause the sys.stdout object to be lost or incorrectly initialized.

Here is few possible solutions to this problem:

  1. Reinstall Python: Try reinstalling Python to update or repair broken files and settings.

  2. Check the environment: Make sure the PYTHONHOME and PYTHONPATH environment variables are set correctly. They must point to the correct Python directories.

  3. Set Defaults: Make sure you don't have any custom code or settings that could change or corrupt standard output (sys.stdout). Check that there is no misuse of the sys.stdout object in your code.

huangapple
  • 本文由 发表于 2023年5月7日 00:28:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189981.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定