Python 没有打开 .py 文件 [英] Python is not opening .py files

查看:50
本文介绍了Python 没有打开 .py 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的计算机上打开一个 .py 脚本,但不幸的是它一直在记事本中打开.我尝试更改计算机上的关联,但即使我浏览到 python.exe 并单击它,它也不会显示为可用程序(有趣的是,pythonw.exe 可以与之关联,但单击时没有任何打开)在与 pythonw 关联的文件上).有什么办法可以解决这个问题吗?如果没有,我如何手动从 Python 解释器运行我的脚本?

I'm trying to open a .py script on my computer but it unfortunately keeps opening in Notepad. I've tried changing the associations on my computer but even when I browse to python.exe and click it, it won't show up as a usable program (interestingly, pythonw.exe can be associated with it but nothing opens when I click on the file that's associated to pythonw). Is there any way I can fix this issue? If not, how can I run my script from the Python interpreter by hand?

另外,我试过重新安装 Python,但没有帮助.

Also, I've tried reinstalling Python, and that didn't help.

推荐答案

在 Windows 上执行 python 脚本的标准方法是在 (DOS) 命令行上使用脚本名称作为参数调用 python 解释器.尽管 python.exe 的路径必须包含在您的 Path 系统变量中.

The standard way of executing a python script on Windows is calling the python interpreter with the script name as parameter on the (DOS) command line. It is necessary though that the path to python.exe is included in your Path system variable.

python myprogram.py

这篇关于Python 没有打开 .py 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆