Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

permissions - PermissionError [errno 13] when running openpyxl python script in Komodo

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'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I faced the same problem yesterday, but because I dumbly let the workbook open while trying to run the script. Closing it fixed the issue.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...