Linked Questions
279 questions linked to/from How should I write a Windows path in a Python string literal?
558
votes
10
answers
3.3m
views
Error "(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape" [duplicate]
I'm trying to read a CSV file into Python (Spyder), but I keep getting an error. My code:
import csv
data = open("C:\Users\miche\Documents\school\jaar2\MIK\2.6\vektis_agb_zorgverlener")
...
457
votes
10
answers
1.7m
views
"Unicode Error 'unicodeescape' codec can't decode bytes..." when writing Windows file paths [duplicate]
I am using Python 3.1 on a Windows 7 machine. Russian is the default system language, and utf-8 is the default encoding.
Looking at the answer to a previous question, I have attempting using the "...
114
votes
5
answers
259k
views
Why do I get a SyntaxError for a Unicode escape in my file path? [duplicate]
The folder I want to get to is called python and is on my desktop.
I get the following error when I try to get to it
>>> os.chdir('C:\Users\expoperialed\Desktop\Python')
SyntaxError: (...
30
votes
13
answers
174k
views
How to use Chrome Profile in Selenium Webdriver Python 3 [duplicate]
So whenever I try to use my Chrome settings (the settings I use in the default browser) by adding
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\Users\... (my ...
34
votes
4
answers
126k
views
IOError: [Errno 22] invalid mode ('r') or filename: 'c:\\Python27\test.txt' [duplicate]
What is wrong with the following:
test_file=open('c:\\Python27\test.txt','r')
43
votes
5
answers
189k
views
How to get rid of double backslash in python windows file path string? [duplicate]
I have a dictionary:
my_dictionary = {"058498":"table", "064165":"pen", "055123":"pencil"}
I iterate over it:
for item in my_dictionary:
PDF = r'C:\Users\user\Desktop\File_%s.pdf' %item
doIt(...
7
votes
7
answers
44k
views
"EOL while scanning single-quoted string"? (backslash in string) [duplicate]
import os
xp1 = "\Documents and Settings\"
xp2 = os.getenv("USERNAME")
print xp1+xp2
Gives me error
File "1.py", line 2
xp1 = "\Documents and Settings\"
^
SyntaxError:...
13
votes
1
answer
40k
views
Creating a file in a non-existing folder using OpenCV in Python [duplicate]
i am trying to create an image file using opencv in python.
when i am creating it in same folder file is created
face_file_name = "te.jpg"
cv2.imwrite(face_file_name, image)
but ...
21
votes
3
answers
52k
views
Region: IOError: [Errno 22] invalid mode ('w') or filename [duplicate]
I'm not sure why, but for some reason, whenever I have "region" in the file name of the output file, it gives me this error:
IOError: [Errno 22] invalid mode ('w') or filename: 'path\regionlog.txt'
...
30
votes
1
answer
150k
views
Python windows path slash [duplicate]
I am facing a very basic problem using directory path in python script. When I do copy path from the windows explorer, it uses backward slash as path seperator which is causing problem.
>>> ...
6
votes
3
answers
26k
views
'CSV does not exist' - Pandas DataFrame [duplicate]
I'm having difficulty reading a csv file into the pandas data frame. I am a total newcomer to pandas, and this is preventing me from progressing. I have read the documentation and searched for ...
9
votes
4
answers
112k
views
Raw strings containing Windows paths produce "SyntaxError: unterminated string literal" [duplicate]
I am trying to use a shutil script I found, but running it triggers:
SyntaxError: unterminated string literal (detected at line 4)
This is maybe related to the script containing raw windows paths. ...
8
votes
2
answers
75k
views
Python error: "cannot find path specified" [duplicate]
import os
import random
os.chdir("C:\Users\Mainuser\Desktop\Lab6")
#Am i supposed to have a os.chdir?
# I think this is what's giving the error
#how do i fix this?
def getDictionary():
...
10
votes
1
answer
111k
views
Python -How to solve OSError: [Errno 22] Invalid argument [duplicate]
I am learning about file objects in python but whenever i try to open file it shows the following error.
I have already checked that file is in same directory and it exists
this error occurs only if i ...
2
votes
1
answer
51k
views
FileNotFoundError: [Errno 2] [duplicate]
Synopsis:
How do I read a file in Python?
why must it be done this way?
My problem is that I get the following error:
Traceback (most recent call last):
File "C:\Users\Terminal\Desktop\wkspc\...