Part 2 00_exports.ipynb does not run on !python notebook2script.py xxx.ipynb

Hi there, I ran into a error when I executed the cell in the 1st notebook of Part 2 course 00_exports.ipynb

!python notebook2script.py 00_exports.ipynb

File "notebook2script.py", line 56
    fname_out = f'nb_{fname.stem.split("_")[0]}.py'
                                                  ^
SyntaxError: invalid syntax

I had installed all the packages in my environment, such as fire etc. What is the .stem method here? It seems to me that fname is a str which does not has method stem. Correct me if I am wrong.

Stem on a filename is the filename without the extension.
E.g. the stem of filename1.txt would be filename1
For more info Google ‘python stem filename’
So there is perhaps something wrong with the filename assignment.

Hi Paul

This is normally the export at the end of the notebook

!python notebook2script.py 07_batchnorm.ipynb
which creates Converted 07_batchnorm.ipynb to exp/nb_07.py
which you import as
#export
from exp.nb_07 import *

stem should return the file name without suffix so ```
00_exports.ipynb becomes 00_exports

I wonder if the notebook has changed.

Regards Conwyn

1 Like