【发布时间】: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.6或python 3.8中使用哪个版本 -
@Aditya 我已经编辑了我的问题以试图解释这一点。
-
我建议使用虚拟环境来避免此类问题
-
@DerekEden 我不认为我可以制作一个 python 3.6 虚拟环境,因为我无法让它运行
-
当你安装了两个(或更多)版本的python时,你应该在开头添加一个shebang命令来指定要运行的版本,然后通过
py命令运行脚本。请参阅Python Launcher for Windows int 文档。
标签: python python-3.x windows