# Error code in Python

**URL:** <https://discuss.python.org/t/error-code-in-python/22673>\
**Category:** Python Help\
**Created:** [January 11, 2023, 9:10am UTC](https://discuss.python.org/t/error-code-in-python/22673 "2023-01-11T09:10:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mfmalthaf](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mfmalthaf](https://discuss.python.org/u/mfmalthaf)\
**Post date:** [January 11, 2023, 9:10am UTC](https://discuss.python.org/t/error-code-in-python/22673/1 "2023-01-11T09:10:34Z")

</div>

Hi i’m getting an error when trying to read an excel which is in (xlsx) format, this excel has links to other excels.  
and same code works when i use .xls

**error code image**

 ![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/3/30e0e5b7a1cc670c800280f491e97bed2ac39646.png)

---

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [January 11, 2023, 10:03am UTC](https://discuss.python.org/t/error-code-in-python/22673/2 "2023-01-11T10:03:46Z")

</div>

Its impossible to say, because we can’t see the entire traceback.

What IDE are you using? It is displaying so much extra information that the _important_ information is hidden.

> [@](#):
>
> same code works when i use .xls

If it works when you use .xls, and doesn’t work when you use .xlsx, then you should use .xls.

Without seeing the rest of the error, I cannot even guess what the problem is with the .xlsx file. Maybe it doesn’t exist?

---

<div class="post-metadata">

**Author:** ![mfmalthaf](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mfmalthaf](https://discuss.python.org/u/mfmalthaf)\
**Post date:** [January 11, 2023, 10:42am UTC](https://discuss.python.org/t/error-code-in-python/22673/3 "2023-01-11T10:42:04Z")

</div>

Thank you for your reply, please note that Im new to Python and to this forum. Im not sure what you mean by IDE,  
anyway i’m using Jupiter note book launched from Anaconda.

file exists in the mentioned path. i double checked.

if you want me to show the entire error report, i don’t know how to do it in this forum there is no option to attach a file

---

<div class="post-metadata">

**Author:** ![MRAB](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@MRAB](https://discuss.python.org/u/MRAB)\
**Post date:** [January 11, 2023, 7:15pm UTC](https://discuss.python.org/t/error-code-in-python/22673/4 "2023-01-11T19:15:22Z")

</div>

Copy and paste the code and the complete traceback. The code and the traceback should be posted wrapped in triple backticks to preserve the formatting.

For the code:

````auto
```python
if True:
    print(''Hello world!')
```

````

and for the traceback:

````auto
```
traceback stuff
```

````

---

<div class="post-metadata">

**Author:** ![cameron](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cameron/32/2658_2.png) [@cameron](https://discuss.python.org/u/cameron)\
**Post date:** [January 11, 2023, 10:05pm UTC](https://discuss.python.org/t/error-code-in-python/22673/5 "2023-01-11T22:05:17Z")

</div>

It looks like a Jupyter notebook to me, a rather nice interactive Python  
env with “cells” which are either markdown text or Python code, thus  
providing a form of literate programming and also lending itself to be  
the basis of an explained workflow for whatever purpose.

Cheers,  
Cameron Simpson [cs@cskk.id.au](mailto:cs@cskk.id.au)

---

<div class="post-metadata">

**Author:** ![mfmalthaf](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mfmalthaf](https://discuss.python.org/u/mfmalthaf)\
**Post date:** [January 12, 2023, 4:49pm UTC](https://discuss.python.org/t/error-code-in-python/22673/6 "2023-01-12T16:49:51Z")

</div>

**For the Code**

import pandas as pd

file\_path = ‘D:\Mohommed.Althaf\Desktop\WIP\a.xlsx’  
df = pd.read\_excel(file\_path)  
print(df)

**for the traceback:**

* * *

ValueError Traceback (most recent call last)  
Input In [54], in \<cell line: 4\>()  
1 import pandas as pd  
3 file\_path = ‘D:\Mohommed.Althaf\Desktop\WIP\a.xlsx’  
----\> 4 df = pd.read\_excel(file\_path)  
5 print(df)

File ~\Anaconda3\lib\site-packages\pandas\util\_decorators.py:311, in deprecate\_nonkeyword\_arguments..decorate..wrapper(\*args, \*\*kwargs)  
305 if len(args) \> num\_allow\_args:  
306 warnings.warn(  
307 msg.format(arguments=arguments),  
308 FutureWarning,  
309 stacklevel=stacklevel,  
310 )  
 → 311 return func(\*args, \*\*kwargs)

File ~\Anaconda3\lib\site-packages\pandas\io\excel\_base.py:457, in read\_excel(io, sheet\_name, header, names, index\_col, usecols, squeeze, dtype, engine, converters, true\_values, false\_values, skiprows, nrows, na\_values, keep\_default\_na, na\_filter, verbose, parse\_dates, date\_parser, thousands, decimal, comment, skipfooter, convert\_float, mangle\_dupe\_cols, storage\_options)  
455 if not isinstance(io, ExcelFile):  
456 should\_close = True  
 → 457 io = ExcelFile(io, storage\_options=storage\_options, engine=engine)  
458 elif engine and engine != io.engine:  
459 raise ValueError(  
460 "Engine should not be specified when passing "  
461 “an ExcelFile - ExcelFile already has the engine set”  
462 )

File ~\Anaconda3\lib\site-packages\pandas\io\excel\_base.py:1419, in ExcelFile. **init** (self, path\_or\_buffer, engine, storage\_options)  
1416 self.engine = engine  
1417 self.storage\_options = storage\_options  
 → 1419 self.\_reader = self.\_engines[engine](self.\_io, storage\_options=storage\_options)

File ~\Anaconda3\lib\site-packages\pandas\io\excel\_openpyxl.py:525, in OpenpyxlReader. **init** (self, filepath\_or\_buffer, storage\_options)  
514 “”"  
515 Reader using openpyxl engine.  
516  
(…)  
522 passed to fsspec for appropriate URLs (see `_get_filepath_or_buffer`)  
523 “”"  
524 import\_optional\_dependency(“openpyxl”)  
 → 525 super(). **init** (filepath\_or\_buffer, storage\_options=storage\_options)

File ~\Anaconda3\lib\site-packages\pandas\io\excel\_base.py:518, in BaseExcelReader. **init** (self, filepath\_or\_buffer, storage\_options)  
516 self.handles.handle.seek(0)  
517 try:  
 → 518 self.book = self.load\_workbook(self.handles.handle)  
519 except Exception:  
520 self.close()

File ~\Anaconda3\lib\site-packages\pandas\io\excel\_openpyxl.py:536, in OpenpyxlReader.load\_workbook(self, filepath\_or\_buffer)  
533 def load\_workbook(self, filepath\_or\_buffer: FilePath | ReadBuffer[bytes]):  
534 from openpyxl import load\_workbook  
 → 536 return load\_workbook(  
537 filepath\_or\_buffer, read\_only=True, data\_only=True, keep\_links=False  
538 )

File ~\Anaconda3\lib\site-packages\openpyxl\reader\excel.py:317, in load\_workbook(filename, read\_only, keep\_vba, data\_only, keep\_links)  
290 “”“Open the given filename and return the workbook  
291  
292 :param filename: the path to open or a file-like object  
(…)  
313  
314 “””  
315 reader = ExcelReader(filename, read\_only, keep\_vba,  
316 data\_only, keep\_links)  
 → 317 reader.read()  
318 return reader.wb

File ~\Anaconda3\lib\site-packages\openpyxl\reader\excel.py:281, in ExcelReader.read(self)  
279 self.read\_properties()  
280 self.read\_theme()  
 → 281 apply\_stylesheet(self.archive, self.wb)  
282 self.read\_worksheets()  
283 self.parser.assign\_names()

File ~\Anaconda3\lib\site-packages\openpyxl\styles\stylesheet.py:198, in apply\_stylesheet(archive, wb)  
195 return wb  
197 node = fromstring(src)  
 → 198 stylesheet = Stylesheet.from\_tree(node)  
200 if stylesheet.cell\_styles:  
202 wb.\_borders = IndexedList(stylesheet.borders)

File ~\Anaconda3\lib\site-packages\openpyxl\styles\stylesheet.py:103, in Stylesheet.from\_tree(cls, node)  
101 for k in attrs:  
102 del node.attrib[k]  
 → 103 return super(Stylesheet, cls).from\_tree(node)

File ~\Anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py:83, in Serialisable.from\_tree(cls, node)  
79 continue  
81 if hasattr(desc, ‘from\_tree’):  
82 #descriptor manages conversion  
—\> 83 obj = desc.from\_tree(el)  
84 else:  
85 if hasattr(desc.expected\_type, “from\_tree”):  
86 #complex type

File ~\Anaconda3\lib\site-packages\openpyxl\descriptors\sequence.py:85, in NestedSequence.from\_tree(self, node)  
84 def from\_tree(self, node):  
—\> 85 return [self.expected\_type.from\_tree(el) for el in node]

File ~\Anaconda3\lib\site-packages\openpyxl\descriptors\sequence.py:85, in (.0)  
84 def from\_tree(self, node):  
—\> 85 return [self.expected\_type.from\_tree(el) for el in node]

File ~\Anaconda3\lib\site-packages\openpyxl\styles\fonts.py:109, in Font.from\_tree(cls, node)  
107 if underline is not None and underline.get(‘val’) is None:  
108 underline.set(“val”, “single”)  
 → 109 return super(Font, cls).from\_tree(node)

File ~\Anaconda3\lib\site-packages\openpyxl\descriptors\serialisable.py:103, in Serialisable.from\_tree(cls, node)  
100 else:  
101 attrib[tag] = obj  
 → 103 return cls(\*\*attrib)

File ~\Anaconda3\lib\site-packages\openpyxl\styles\fonts.py:75, in Font. **init** (self, name, sz, b, i, charset, u, strike, color, scheme, family, size, bold, italic, strikethrough, underline, vertAlign, outline, shadow, condense, extend)  
69 def **init** (self, name=None, sz=None, b=None, i=None, charset=None,  
70 u=None, strike=None, color=None, scheme=None, family=None, size=None,  
71 bold=None, italic=None, strikethrough=None, underline=None,  
72 vertAlign=None, outline=None, shadow=None, condense=None,  
73 extend=None):  
74 self.name = name  
—\> 75 self.family = family  
76 if size is not None:  
77 sz = size

File ~\Anaconda3\lib\site-packages\openpyxl\descriptors\nested.py:35, in Nested. **set** (self, instance, value)  
32 raise ValueError(“Tag does not match attribute”)  
34 value = self.from\_tree(value)  
—\> 35 super(Nested, self). **set** (instance, value)

File ~\Anaconda3\lib\site-packages\openpyxl\descriptors\base.py:108, in Min. **set** (self, instance, value)  
106 if value \< self.min:  
107 raise ValueError(‘Min value is {0}’.format(self.min))  
 → 108 super(Min, self). **set** (instance, value)

File ~\Anaconda3\lib\site-packages\openpyxl\descriptors\base.py:87, in Max. **set** (self, instance, value)  
85 value = \_convert(self.expected\_type, value)  
86 if value \> self.max:  
—\> 87 raise ValueError(‘Max value is {0}’.format(self.max))  
88 super(Max, self). **set** (instance, value)

ValueError: Max value is 14

---

<div class="post-metadata">

**Author:** ![MRAB](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@MRAB](https://discuss.python.org/u/MRAB)\
**Post date:** [January 12, 2023, 5:54pm UTC](https://discuss.python.org/t/error-code-in-python/22673/7 "2023-01-12T17:54:58Z")

</div>

I think it’s complaining about a font size in the spreadsheet, but I can’t be sure.

---

<div class="post-metadata">

**Author:** ![mfmalthaf](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@mfmalthaf](https://discuss.python.org/u/mfmalthaf)\
**Post date:** [January 13, 2023, 3:12am UTC](https://discuss.python.org/t/error-code-in-python/22673/8 "2023-01-13T03:12:10Z")

</div>

Hi i’m getting an error when when the excel file is in (xlsx) format, this excel has links to other excels too.

and same code works for same file when I use .xls
