Full error message looks like
Traceback (most recent call last): File "/home/alex/PythonProjects/nbdev_env/bin/nbdev_new", line 8, in <module> sys.exit(nbdev_new()) ^^^^^^^^^^^ File "/home/alex/PythonProjects/nbdev_env/lib/python3.12/site-packages/fastcore/script.py", line 119, in _f return tfunc(**merge(args, args_from_prog(func, xtra))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/alex/PythonProjects/nbdev_env/lib/python3.12/site-packages/nbdev/cli.py", line 91, in nbdev_new _TEMPLATE = f'{_ORG_OR_USR}/{_TEMPLATE}' ^^^^^^^^^ UnboundLocalError: cannot access local variable '_TEMPLATE' where it is not associated with a value
_TEMPLATE = f'{_ORG_OR_USR}/{_TEMPLATE}'
In this statement variable _TEMPLATE is used before assignment
Probably this is misprint and '_REPOSITORY' should be used instead of '_TEMPLATE'
How to fix locally
nbdev_new - initial command when creating project with nbdev, so it is not possible to use functionality of the library without it.
Steps to fix locally:
Create python venv and activate it.
Install nbdev and jupyter lab according to the tutorial mentioned above.
Command to reproduce the error
Error occured at the moment of execution 'nbdev_new' command (https://nbdev.fast.ai/tutorials/tutorial.html#initialise-your-repo-with-nbdev) inside python venv with installed nbdev library.
Detail description
Full error message looks like
Traceback (most recent call last): File "/home/alex/PythonProjects/nbdev_env/bin/nbdev_new", line 8, in <module> sys.exit(nbdev_new()) ^^^^^^^^^^^ File "/home/alex/PythonProjects/nbdev_env/lib/python3.12/site-packages/fastcore/script.py", line 119, in _f return tfunc(**merge(args, args_from_prog(func, xtra))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/alex/PythonProjects/nbdev_env/lib/python3.12/site-packages/nbdev/cli.py", line 91, in nbdev_new _TEMPLATE = f'{_ORG_OR_USR}/{_TEMPLATE}' ^^^^^^^^^ UnboundLocalError: cannot access local variable '_TEMPLATE' where it is not associated with a value
OS and Python versions
OS: Ubuntu 24.04 LTS Python version: Python 3.12.3 nbdev version: nbdev 2.3.19
nbdev library was installed with help of pip: pip 24.0 from /home/alex/PythonProjects/nbdev_env/lib/python3.12/site-packages/pip (python 3.12)
Possible reason of the error
It is possible that the source of error is the incorrect argument to f - string. https://github.com/fastai/nbdev/blob/master/nbs/api/13_cli.ipynb, function _nbdevnew.
_TEMPLATE = f'{_ORG_OR_USR}/{_TEMPLATE}'
In this statement variable _TEMPLATE is used before assignmentProbably this is misprint and '_REPOSITORY' should be used instead of '_TEMPLATE'
How to fix locally
nbdev_new - initial command when creating project with nbdev, so it is not possible to use functionality of the library without it. Steps to fix locally:
pip uninstall nbdev
)pip install .
nbdev_new