在 Komodo 中运行 openpyxl python 脚本时出现 PermissionError [errno 13] [英] PermissionError [errno 13] when running openpyxl python script in Komodo

查看:39
本文介绍了在 Komodo 中运行 openpyxl python 脚本时出现 PermissionError [errno 13]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 7 上的 Komodo edit 9 和 python 3.4 中使用 openpyxl 脚本时遇到问题.我复制了一些 openpyxl 代码来学习,但它不会从 Komodo 执行.我收到一个权限错误 13.我检查了我的路径并且存在 python34.当我使用 IDLE 或命令提示符时,将运行相同的脚本.我的 Komodo 命令目前是:%(python3) -u %F关于可能导致此问题的任何想法?代码和错误包含在下面

I am having trouble using openpyxl scripts in Komodo edit 9 and python 3.4 on Windows 7. I copied some openpyxl code to learn, but it won't execute from Komodo. I receive a permission error 13. I checked my path and python34 is present. The same script will run when I use IDLE or Command Prompt. My Komodo command is currently: %(python3) -u %F Any ideas on what may be causing this issue? The code and error are included below

from openpyxl import Workbook
from openpyxl.compat import range
from openpyxl.cell import get_column_letter

wb = Workbook()

dest_filename = 'empty_book.xlsx'

ws1 = wb.active
ws1.title = "range names"

for row in range(1, 40):
    ws1.append(range(600))

ws2 = wb.create_sheet(title="Pi")

ws2['F5'] = 3.14

ws3 = wb.create_sheet(title="Data")
for row in range(10, 20):
    for col in range(27, 54):
        _ = ws3.cell(column=col, row=row, value="%s" % get_column_letter(col))
print(ws3['AA10'].value)
wb.save(filename = dest_filename)

-------开始错误-----------

-------Begin Error-----------

AA
Traceback (most recent call last):
  File "C:UsersPF15043DesktopScriptsGgizmoexcelReader.py", line 26, in <module>
    wb.save(filename = dest_filename)
  File "C:Python34libsite-packagesopenpyxl-2.3.0b1-py3.4.eggopenpyxlworkbookworkbook.py", line 254, in save
    save_workbook(self, filename)
  File "C:Python34libsite-packagesopenpyxl-2.3.0b1-py3.4.eggopenpyxlwriterexcel.py", line 195, in save_workbook
    writer.save(filename, as_template=as_template)
  File "C:Python34libsite-packagesopenpyxl-2.3.0b1-py3.4.eggopenpyxlwriterexcel.py", line 177, in save
    archive = ZipFile(filename, 'w', ZIP_DEFLATED, allowZip64=True)
  File "C:Python34libzipfile.py", line 923, in __init__
    self.fp = io.open(file, modeDict[mode])
PermissionError: [Errno 13] Permission denied: 'empty_book.xlsx'

推荐答案

这只是来自操作系统的错误,告诉您您没有权限在您尝试创建的位置创建文件.您应该指定您尝试创建的文件的完整路径.

This is simply an error from the operating system telling you that you don't have permissions to create a file where you're trying to. You should specify the full path of the file you're trying to create.

这篇关于在 Komodo 中运行 openpyxl python 脚本时出现 PermissionError [errno 13]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆