Hey everyone,
I’m getting a no module named
error for installed packages.
Earlier I was using nbdev
package installed locally (not virtual environment). Although the nbdev
commands were working in my terminal and jupyter lab terminal as desired, I got the no module named
when importing nbdev
in the notebook.
Assuming it to be a package issue, I let it be.
Now again, for a different project, I’m getting the same issue when importing packages such as fastai
, torch
, and keras
in both virtual and local environments where they are installed;
Even after doing a !pip install
in the notebook, I get the same error.
At the same time and environment, I can import libraries/packages such as pandas
, or numpy
.
What may be the issue, and how may I resolve it?
Thank you.
I resolved this kind of issue by granting 755 permission on site-packages folder and subfolder
1 Like
For a better experience in modern Jupyter, you should shift to using the more current %pip install
when attempting to do installations from inside a running Jupyter .ipynb
file. That ensures the commands target the environment where the kernel backing the notebook is running. The exclamation point used in conjunction with install commands doesn’t do that and so it may lead to unexpected outcomes.
See more about the modern %pip install
command here added in 2019 for a better experience with such installs performed from in a cell inside a running notebook. The second paragraph here goes into more details about why the exclamation point may lead to issues.
This likely will not have any effect in your current situation, yet it will pay dividends later going forward in your Jupyter experience wherever you use modern Jupyter as it works in JupyterLite and even Google Colab now.
3 Likes
Oh nice, I wasn’t aware that magic commands for pip
and conda
were a thing; will keep them in mind going forward.
What sort of permission, and how to grant them?