简体   繁体   中英

Python: IOError: [Errno 13] Permission denied error? Privacy setting?

I am trying to run the code as listed on Github, https://github.com/duytinvo/ijcai2015 . However, after running the command: python targetdep+.py, I received the following error:

IOError: [Errno 13] Permission denied: '../data/output/training'

This is the part of the code that caused the error:

def writevec(filename,x,y):
f=open(filename,'wb')
for i in xrange(len(y)):
    f.write(str(y[i])+'\t')
    feature=x[i]
    for (j,k) in enumerate(feature):
        f.write(str(j+1)+':'+str(k)+' ')
    f.write('\n')
f.close() 

if __name__ == "__main__":
    features=targettw()
    print "extracting features for training"
    x_train,y_train=features.allfeat('../data/training/')
    writevec('../data/output/training',x_train,y_train)
    print "extracting features for testing"
    x_test,y_test=features.allfeat('../data/testing/')
    writevec('../data/output/testing',x_test,y_test)

Anyone knows what have I done wrongly? How can I resolve this error? Thanks in advance!

There is a limit in Windows on how long directory/file-names can be in order to open them. Having a too long name will cause weird problems.

If this is the case, here is a good explanation: Why does the 260 character path length limit exist in Windows?

I'd suggest you move your project or the output dir somewhere else, for intsance to r'C:\\Users\\NANA\\Desktop\\output' and see if that helps.

This solution comes from comments above and might or might not solve the OP's problem but could be useful for others with similra "odd" issues.

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