【问题标题】:Second installation of python will not run on Windows二次安装python将无法在Windows上运行
【发布时间】:2020-07-19 19:37:29
【问题描述】:

我已经安装了 python 3.8,但还需要安装没有错误的 python 3.6。我想在 cmd 中的任何位置使用命令 python 运行 python 3.8,然后从特定文件 C:Python\Python36\python.exe 运行 python 3.6 所以没有将 python 3.6 添加到 PATH。但是,当我尝试运行 python 3.6 时,我收到此错误:

Fatal Python error: Py_Initialize: can`t initialize sys standard streams
Traceback (most recent call last):
  File "C:Python\Python38\lib\abc.py", line 64, in <module>
ModuleNotFoundError: No module named '_abc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:Python\Python38\lib\io.py", line 52, in <module>
  File "C:Python\Python38\lib\abc.py", line 68, in <module>
  File "C:Python\Python38\lib\_py_abc.py", line 35
    def __new__(mcls, name, bases, namespace, /, **kwargs):
                                              ^
SyntaxError: invalid syntax

我不知道为什么当我运行 Python36/python.exe 时,它​​会尝试访问 python 3.8 模块。我试过卸载和安装。有什么想法吗?

【问题讨论】:

  • python 安装是否都在你的环境变量中。还要尝试明确说明您需要在 cmd.python 3.6python 3.8 中使用哪个版本
  • @Aditya 我已经编辑了我的问题以试图解释这一点。
  • 我建议使用虚拟环境来避免此类问题
  • @DerekEden 我不认为我可以制作一个 python 3.6 虚拟环境,因为我无法让它运行
  • 当你安装了两个(或更多)版本的python时,你应该在开头添加一个shebang命令来指定要运行的版本,然后通过py命令运行脚本。请参阅Python Launcher for Windows int 文档。

标签: python python-3.x windows


【解决方案1】:

环境变量有问题。 PYTHONHOME 环境变量设置为 python 3.8 目录。一旦我删除了这个变量,问题就解决了。

【讨论】:

    猜你喜欢
    • 2016-02-10
    • 2018-01-18
    • 2015-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-23
    • 2019-07-13
    • 1970-01-01
    相关资源
    最近更新 更多