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
JavaScript
x
25
25
1
from openpyxl import Workbook
2
from openpyxl.compat import range
3
from openpyxl.cell import get_column_letter
4
5
wb = Workbook()
6
7
dest_filename = 'empty_book.xlsx'
8
9
ws1 = wb.active
10
ws1.title = "range names"
11
12
for row in range(1, 40):
13
ws1.append(range(600))
14
15
ws2 = wb.create_sheet(title="Pi")
16
17
ws2['F5'] = 3.14
18
19
ws3 = wb.create_sheet(title="Data")
20
for row in range(10, 20):
21
for col in range(27, 54):
22
_ = ws3.cell(column=col, row=row, value="%s" % get_column_letter(col))
23
print(ws3['AA10'].value)
24
wb.save(filename = dest_filename)
25
——-Begin Error———–
JavaScript
1
14
14
1
AA
2
Traceback (most recent call last):
3
File "C:UsersPF15043DesktopScriptsGgizmoexcelReader.py", line 26, in <module>
4
wb.save(filename = dest_filename)
5
File "C:Python34libsite-packagesopenpyxl-2.3.0b1-py3.4.eggopenpyxlworkbookworkbook.py", line 254, in save
6
save_workbook(self, filename)
7
File "C:Python34libsite-packagesopenpyxl-2.3.0b1-py3.4.eggopenpyxlwriterexcel.py", line 195, in save_workbook
8
writer.save(filename, as_template=as_template)
9
File "C:Python34libsite-packagesopenpyxl-2.3.0b1-py3.4.eggopenpyxlwriterexcel.py", line 177, in save
10
archive = ZipFile(filename, 'w', ZIP_DEFLATED, allowZip64=True)
11
File "C:Python34libzipfile.py", line 923, in __init__
12
self.fp = io.open(file, modeDict[mode])
13
PermissionError: [Errno 13] Permission denied: 'empty_book.xlsx'
14
Advertisement
Answer
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.