I'm using python (np.loadtxt) to open text file which is created in windowsOS, and trying to use it in macOS. The python script is working just fine on my windows, but it is giving me UnicodeDecodeError: 'utf-8' codec can't decode byte 0x87 in position 23: invalid start byte error when I try to use the same script on macbook. It seems like it's caused by file names, because the line this error occured is the line I'm reading text file.
for names in os.listdir(dir_2):
array_txt = np.loadtxt(dir_2+"/"+names)
x = array_txt[:800,0]
y = array_txt[:800,1]
I googled it and tried str = unicode(str, errors='replace') on my file name string. But still got error that says name 'unicode' is not defined. I installed unidecode, and also tried importing unicodedata but couldn't fix it. I also tried creating text file on the macbook and copying the data from original file, but still got the same error. I also found someone saying it's a bug in numpy, but I'm not sure if I'm experiencing the bug or is it something different. Can someone give explanations? Thank you in advance.