KeyError: "Style 'normal' not found in stylesheet"
See original GitHub issuev0.95 seem to have introduced a bug which results in KeyError: "Style 'normal' not found in stylesheet"
:
Steps to reproduce
- Create a directory:
cd /tmp
mkdir repro
cd repro
- Create
Vagrantfile
with following contents:
# -*- mode: ruby -*-
# vi: set ft=ruby :
$script = <<-SCRIPT
sudo apt-get update
sudo apt-get install python python-pip python-virtualenv -y
python -V
virtualenv .venv
source .venv/bin/activate
pip install rst2pdf==0.95
touch empty.rst
rst2pdf ./empty.rst -o result.pdf
SCRIPT
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.provision "shell", inline: $script
end
- Run
vagrant up
In the end script fails with:
default: Traceback (most recent call last):
default: File "/home/vagrant/.venv/bin/rst2pdf", line 8, in <module>
default:
default: sys.exit(main())
default: File "/home/vagrant/.venv/local/lib/python2.7/site-packages/rst2pdf/createpdf.py", line 1491, in main
default:
default: strip_elements_with_classes=options.strip_elements_with_classes,
default: File "/home/vagrant/.venv/local/lib/python2.7/site-packages/rst2pdf/createpdf.py", line 173, in __init__
default:
default: self.loadStyles(stylesheets)
default: File "/home/vagrant/.venv/local/lib/python2.7/site-packages/rst2pdf/createpdf.py", line 276, in loadStyles
default:
default: def_dpi=self.def_dpi)
default: File "/home/vagrant/.venv/local/lib/python2.7/site-packages/rst2pdf/styles.py", line 532, in __init__
default:
default: self.emsize = self['base'].fontSize
default: File "/home/vagrant/.venv/local/lib/python2.7/site-packages/rst2pdf/styles.py", line 557, in __getitem__
default:
default: newst = copy(self.StyleSheet['normal'])
default: File "/home/vagrant/.venv/local/lib/python2.7/site-packages/reportlab/lib/styles.py", line 224, in __getitem__
default:
default: raise KeyError("Style '%s' not found in stylesheet" % key)
default: KeyError
default: :
default: "Style 'normal' not found in stylesheet"
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
The issue is not present with v0.94.1
🖥 Versions
- Python 2.7.17
- rst2pdf==0.95
- reportlab==3.5.32
- Ubuntu 18.04
(.venv) vagrant@ubuntu-bionic:~$ pip freeze
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
docutils==0.15.2
Jinja2==2.10.3
MarkupSafe==1.1.1
pdfrw==0.4
Pillow==6.2.2
pkg-resources==0.0.0
Pygments==2.5.2
reportlab==3.5.32
rst2pdf==0.95
six==1.13.0
smartypants==2.0.1
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
KeyError when trying to access ['style'] using Beautiful Soup
KeyError when trying to access ['style'] using Beautiful Soup · No, the div tag has no style attribute. I don't see any tag...
Read more >KeyError: "Style 'normal' not found in stylesheet" - Bountysource
KeyError : "Style 'normal' not found in stylesheet"
Read more >src/reportlab/lib/styles.py - Fossies
10 11 ParagraphStyle shows all the attributes available for formatting ... KeyError: 224 raise KeyError("Style '%s' not found in stylesheet" ...
Read more >Working with Styles — python-docx 0.8.11 documentation
Working with Styles¶ ... styles['Normal'] <docx.styles.style. ... User-defined styles, also known as custom styles, are not localized and are accessed with ...
Read more >Python KeyError Exceptions and How to Handle Them
When you see a KeyError , the semantic meaning is that the key being looked for could not be found. In the example...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
There is no
styles
directory inrst2pdf
:But there is
styles.py
file. It may conflict with thestyles
directory, ifstyles
directory contains__init__.py
. I suspect there might be a bug insetup.py
orsetup.cfg
.0.97 is now release with this fix in it.