Jump to content

Python failed to execute script

Wictorian

I can run the script using IDLE with no issues at all but when I left click it gives warning "failed to execute script". Is there any chance you know how I can solve this?

 

Link to comment
Share on other sites

Link to post
Share on other sites

I assume you're running Windows 10; if not please correct me.

 

Do you mean you're right-clicking in the file explorer? What option are you selecting from the drop down menu?

 

Where is "Failed to execute script" appearing? In a pop-up dialog box?

____________________________________________________________________________________________________________________________________

 

 

____________________________________________________________________________________________________________________________________

pythonmegapixel

into tech, public transport and architecture // amateur programmer // youtuber // beginner photographer

Thanks for reading all this by the way!

By the way, my desktop is a docked laptop. Get over it, No seriously, I have an exterrnal monitor, keyboard, mouse, headset, ethernet and cooling fans all connected. Using it feels no different to a desktop, it works for several hours if the power goes out, and disconnecting just a few cables gives me something I can take on the go. There's enough power for all games I play and it even copes with basic (and some not-so-basic) video editing. Give it a go - you might just love it.

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, pythonmegapixel said:

I assume you're running Windows 10; if not please correct me.

 

Do you mean you're right-clicking in the file explorer? What option are you selecting from the drop down menu?

 

Where is "Failed to execute script" appearing? In a pop-up dialog box?

Yes

 

silly me, I mean left clicking

 

yes

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Wictorian said:

Yes

 

silly me, I mean left clicking

 

yes

OK cool, is there any chance you could run your script at the command prompt and see what the output is?

  • In File Explorer, go to the folder where your script is
  • Delete everything out of the box at the top where the path is displayed, then type cmd in this box and press enter -
  • This will open a command prompt window- here, type python [your-script-name].py - replace [your-script-name].py with the file name of your script.

____________________________________________________________________________________________________________________________________

 

 

____________________________________________________________________________________________________________________________________

pythonmegapixel

into tech, public transport and architecture // amateur programmer // youtuber // beginner photographer

Thanks for reading all this by the way!

By the way, my desktop is a docked laptop. Get over it, No seriously, I have an exterrnal monitor, keyboard, mouse, headset, ethernet and cooling fans all connected. Using it feels no different to a desktop, it works for several hours if the power goes out, and disconnecting just a few cables gives me something I can take on the go. There's enough power for all games I play and it even copes with basic (and some not-so-basic) video editing. Give it a go - you might just love it.

Link to comment
Share on other sites

Link to post
Share on other sites

19 hours ago, pythonmegapixel said:

OK cool, is there any chance you could run your script at the command prompt and see what the output is?

  • In File Explorer, go to the folder where your script is
  • Delete everything out of the box at the top where the path is displayed, then type cmd in this box and press enter -
  • This will open a command prompt window- here, type python [your-script-name].py - replace [your-script-name].py with the file name of your script.

Lol I know how to do it, anyway thanks for being explanatory.

 

It outputs this:

 

  File "<stdin>", line 1
SyntaxError: unexpected character after line continuation character

Link to comment
Share on other sites

Link to post
Share on other sites

4 hours ago, Wictorian said:

It outputs this:

 

  File "<stdin>", line 1
SyntaxError: unexpected character after line continuation character

I've never seen this exact issue before. However, the "unexpected character after line continuation character" error generally indicates that there is a backslash (\) somewhere that the Python interpreter didn't expect to find one.

 

More specifically, the \ character is used to indicate that the next part of a string should be on the same line. So if I run this:

my_string = "This string should \
             all be on \
             the same line"
             
print(my_string)

 

then the output is this:

This string should all be on the same line

 

There are not allowed to be any more characters on the line after the \, and the error you are getting is thrown if there are more characters there.

 

 

Unfortunately I'm unsure why this error would only occur when running the program outside of IDLE. However, if you use backslashes in strings anywhere in your program, or in arguments that you pass to your program, it might be worth getting rid of them and seeing if this fixes the issue?

 

Of course Windows uses \ as the path separator, and from what I've read on other sites, usually this error has something to do with file paths being used somewhere

 

Hopefully this can give you some idea how to fix your issue - if not, hopefully others will come along to assist you, or you could ask somewhere StackOverflow. Sorry I couldn't be of more help!

____________________________________________________________________________________________________________________________________

 

 

____________________________________________________________________________________________________________________________________

pythonmegapixel

into tech, public transport and architecture // amateur programmer // youtuber // beginner photographer

Thanks for reading all this by the way!

By the way, my desktop is a docked laptop. Get over it, No seriously, I have an exterrnal monitor, keyboard, mouse, headset, ethernet and cooling fans all connected. Using it feels no different to a desktop, it works for several hours if the power goes out, and disconnecting just a few cables gives me something I can take on the go. There's enough power for all games I play and it even copes with basic (and some not-so-basic) video editing. Give it a go - you might just love it.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×