简体   繁体   English

Python:IOError:[Errno 13]权限被拒绝错误? 隐私设置?

[英]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 . 我正在尝试运行Github( https://github.com/duytinvo/ijcai2015)上列出的代码。 However, after running the command: python targetdep+.py, I received the following error: 但是,在运行命令:python targetdep + .py之后,我收到以下错误:

IOError: [Errno 13] Permission denied: '../data/output/training' IOError:[Errno 13]权限被拒绝:“ ../ 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. 在Windows中,打开目录/文件名的长度有一个限制。 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? 如果是这种情况,这是一个很好的解释: Windows中为什么存在260个字符的路径长度限制?

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. 我建议您将项目或输出目录移动到其他地方,以保持对r'C:\\Users\\NANA\\Desktop\\output' ,看看是否有帮助。

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. 该解决方案来自上面的评论,可能会或可能不会解决OP的问题,但可能对其他具有类似“奇数”问题的人很有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM