简体   繁体   中英

I'm trying to set up python in notepad++ and it can't understand my filepath that has a space in it

I'm using this tutorial: https://silentcrash.com/2016/12/run-python-script-notepad/

The example for Python 3 includes the folder "Program Files (x86)", which I assume is not necessary, but I would still like to know how to fix this problem if it comes up in the future and I don't have another way of doing it.

So what happens is that the program assumes the space is the end of the command and it move on to the argument as seen here:

The Program to Run

Error

The system cannot find the file specified.
An attempt was made to execute the below command.
------------------------------------------------
Command: C:\Program
Arguments: Files\Python37\Lib\idlelib.py "new 2"
Error Code: 2

Is there any way to write the file path such that it won't be split up like this?

You need to surround your arguments with quotes when they contain spaces. In your example, you would use the following command in the Run... dialog:

"C:\Program Files\Python37\Lib\idlelib.py" "$(FULL_CURRENT_PATH)"

I found a helpful hint on superuser.com that will stop the console window from closing when your script finishes. However, note that it now needs an extra set of quotes.

cmd /k ""C:\Program Files\Python37\Lib\idlelib.py" "$(FULL_CURRENT_PATH)""

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM