首页 > 解决方案 > 在记事本++中运行python脚本不起作用,其他帖子也不起作用

问题描述

最近,(半小时前)我下载了 Notepad++ 来编码而不是 IDLE。

只是为了看看是否一切正常,我创建了这个简单的程序来测试

def test():
    print("hello")

test()

我运行它,然后一个窗口立即打开并关闭。

假设我遇到的问题的答案位于此处:How to Execute a Python File in Notepad ++?我按照说明进行了尝试,但没有成功。然后我用 shift-RBM 复制文件路径而不是页面上的内容,但仍然像以前一样出现错误消息:

The system cannot find the file specified.
An attempt was made to execute the below command.
-------------------------------------------------
Command: C:\Users\----\Desktop\Python
Arguments: 3.5\Python 3.5 (32-bit).Ink
"C:\Users\----\Desktop\test.py" -i
Error Code: 2
-------------------------------------------------

在此之后,我来到这里并提出了这个问题。对不起,如果答案在其他地方说或很明显。

标签: pythonnotepad++python-3.5

解决方案


看起来您在某些文件夹名称中有空间。

要解决此问题,您需要在 python 路径之前和之后使用" 。

例子:

"C:\Users\----\Desktop\Python 3.5\Python 3.5 (32-bit).Ink" "C:\Users\----\Desktop\test.py" -i

推荐阅读