I started developing my own project named nbdev_school using nbdev.
First, I created a dir named nbs to place all notebooks.
Second, created a notebook named student.ipynb to declare Student class.
Third, I exported it to nbdev_school/student using nbdev_export command.
Finally, I tried to import the student module in index.ipynb to build my school.
However, when running from nbdev_school.student import * in index.ipynb,
I got an error below.
ModuleNotFoundError: No module named 'nbdev_school'
I guess the reason of the error above is that we canât import Student inside nbs dir.
Is there a nice way to handle this error?
(The easiest solution is to move all notebooks to top level, but Iâd like to keep it organazed like fast.ai repo).
did you execute nbdev_install ? Your python system needs to be aware of the new library, before you can use it. Even for itself, it seems. (I think nbdev v1 could be used without install, but not sure thatâs true for nbdev v2)
Ah yes, if notebooks were in a sub folder it needed the symlink, but if they were in root, no install was required. Anyhow, most projects grow large enough to justify their own subfolder, donât they?
I have essentially the same problem, but it isnât solved by nbdev_install.
After exporting with nbdev_export I have tried:
pip install -e . (suggested in YouTube tutorial)
pip install -e â.[dev]â (suggested in the âEnd-to-End Walkthroughâ)
nbdev_install (suggested here, with Quarto installed)
None of those seems to make the import work.
I tried following the steps directly from the nbdev tutorial on YouTube for the nbdev_cards project, and canât get that to work. The nbdev_new command creates the nbs dir in the main repo, and when I use nbdev_export the nbdev_card package is at the same level in the repo as nbs. Running index.ipynb within nbs gives the ModuleNotFoundError for the line âfrom nbdev_cards.card import *â
If I move index.ipynb to the top level of the repo, then the import works fine. However, if I take all the files from the nbs dir and put them at the top level of the repo then the export no longer works. Am I missing something?
Hello @bja, welcome to fast.ai forum!
It seems that you have a path issue. I guess your setting.ini is not set properly. Please check if the value ânbsâ is set for ânbs_pathâ like official repo.
If this doesnât help, if possible, please share your GitHub repo so we can look into where your problem is.
Iâm guessing the problem might be related to the UserWarning I got when using nbdev_new to set up the project, but I am not sure. I havenât figure that out yet, and an old post with a similar problem doesnât seem to be resolved.
Update: Updated conda and anaconda, remade the project in a public repo, and ran nbdev_install_hooks again, and now the import seems to work!