There's a very nice package called nb_dev which is designed for authoring Python packages in Jupyter Notebooks. Like nbconvert,
it can turn a notebook into a .py file, but it is more flexible and powerful because it has a lot of nice additional authoring features to help you develop tests, documentation, and register packages on PyPI. It was developed by the fast.ai folks.
It has a bit of a learning curve, but the documentation is good and it is not difficult overall.