'ipykernel (Jupyter notebook/labs) cannot import name ''filefind" from traitlets.utils
I installed Jupyter notebook and labs on and EC2 instance and for some reason I get the following error:
ImportError: cannot import name 'filefind' from 'traitlets.utils' (/usr/lib/python3/dist-packages/traitlets/utils/init.py)
Jupyter opens fine in the browser but I can't seem to be able to work in an python notebook.
Solution 1:[1]
Dirty initial fix (not recommended):
Oke fixed it! It seems like the problem was that the "traitlets/utils/init.py" was empty. So I copy-pasted the code from GitHub and that worked.
https://github.com/ipython/traitlets/blob/main/traitlets/utils/__init__.py
I got this problem twice when I installed two different ec2 instances installing cuda and cudnn. So it might that this has something to do with the origins of this issue.
Proper fix:
The proper way to fix this problem is by upgrading/downgrading the library. Check the other answers to this post for guidance.
Solution 2:[2]
I faced the same issue. Downgrading the versions of traitlets and pygments alone, as suggested by @luarzou, didn't solved the problem for me. I also downgrade ipykernel and it works now:
pip install ipykernel==6.0
I opened an issue: https://github.com/ipython/ipykernel/issues/857
Edit: actually this error can happen when your venv has versions of ipykernel or its dependencies different than the env running jupyter. I suggest in that case to delete and recreate your venv, and verify that you don't install there packages that will break the communication/compatibility.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 |
