Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Python error

So I have a program written in python. When I try to run it it opens for half a second then closes. So I tried to run it from command prompt. It gives an error that I don’t understand. I’ll send a photo of it below. 

 

Link to post
Share on other sites

It's probably the backslashes. Those indicate an escape sequence coming up. \<something> has special meaning, for example \n is a newline or \t is a tab. You'll need to escape your \ if you want to use them in your path there as \\ or prepend the string with r like

 r"C:\Users\R&R"

The r indicates a raw string so it won't try to escape anything.

Crystal: CPU: i7 7700K | Motherboard: Asus ROG Strix Z270F | RAM: GSkill 16 GB@3200MHz | GPU: Nvidia GTX 1080 Ti FE | Case: Corsair Crystal 570X (black) | Storage: 250 GB Crucial BX100 SSD + 2 TB Seagate HDD + 1TB WD Green + 3TB WD Red | PSU: EVGA Supernova G2 1000W | Monitor: Asus VG248QE 24"

Laptop: Dell XPS 13 9360 | CPU: i5 7200U | RAM: 8 GB

Link to post
Share on other sites
Just now, tikker said:

It's probably the backslashes. Those indicate an escape sequence coming up. \<something> has special meaning, for example \n is a newline or \t is a tab. You'll need to escape your \ if you want to use them in your path there as \\ or prepend the string with r like


 r"C:\Users\R&R"

The r indicates a raw string so it won't try to escape anything.

I’m sorry. I understood very little of that. I found the script on GitHub and modified it to work for this computer. Though I ram it on my laptop and it was fine. Can you eli5. 

Link to post
Share on other sites

Oh. Never mind. I reread what you said added an r before the string and it worked. Thank you so much. My sister really wants a ps5 so I’m trying to get her one for Christmas. 

Link to post
Share on other sites
1 minute ago, Rylyguy said:

I’m sorry. I understood very little of that. I found the script on GitHub and modified it to work for this computer. Though I ram it on my laptop and it was fine. Can you eli5. 

https://www.python-ds.com/python-3-escape-sequences

 

Windows uses \ as path separators. This causes a problem, because for Python (and usually) a backslash indicates an escape sequence, which means it will replace it with something else. As I said \n means a new line, for example.

# \n is "escaped" into a new line
print('Hello\nWorld')
Hello
World

# Here the \ is escaped so it won't interpret the \n combination as a new line
print('Hello\\nWorld')
Hello\nWorld

# Here r"" tells Python it's a so-called raw string, so it also won't try to escape anything
print(r'Hello\nWorld')
Hello\nWorld

In your case it tries to interpret \U as a unicode character and fails because what follows isn't valid.

Crystal: CPU: i7 7700K | Motherboard: Asus ROG Strix Z270F | RAM: GSkill 16 GB@3200MHz | GPU: Nvidia GTX 1080 Ti FE | Case: Corsair Crystal 570X (black) | Storage: 250 GB Crucial BX100 SSD + 2 TB Seagate HDD + 1TB WD Green + 3TB WD Red | PSU: EVGA Supernova G2 1000W | Monitor: Asus VG248QE 24"

Laptop: Dell XPS 13 9360 | CPU: i5 7200U | RAM: 8 GB

Link to post
Share on other sites
3 hours ago, Rylyguy said:

So I have a program written in python. When I try to run it it opens for half a second then closes. So I tried to run it from command prompt. It gives an error that I don’t understand. I’ll send a photo of it below. 

 

FYI most big retailers have rate-limit on the requests to their APIs. Besides that envoy will cache identical requests for listing in case of walmart.

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

×