ipykernel (Jupyter notebook/labs) cannot import name ''filefind" from traitlets.utils - python

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.

I disencourage the solution of op. Downloading and overwriting python libraries is not the way of keeping your system stable and clean!
What I found out is that while installing Jupyter notebook it had found four significant errors which resulted from python3 packages that were not installed correctly within that installation itself.
ERROR: ipykernel 6.6.0 has requirement traitlets<6.0,>=5.1.0, but you'll have traitlets 4.3.3 which is incompatible. ERROR: jupyterlab-pygments 0.1.2 has requirement pygments<3,>=2.4.1, but you'll have pygments 2.3.1 which is incompatible. ERROR: nbconvert 6.3.0 has requirement pygments>=2.4.1, but you'll have pygments 2.3.1 which is incompatible. ERROR: nbconvert 6.3.0 has requirement traitlets>=5.0, but you'll have traitlets 4.3.3 which is incompatible.
The solution is to just patch the packages to the newest version with:
pip3 install traitlets==5.1.1
pip3 install pygments==2.4.1
This applies to all similar cases where outdated packages prevent you from your installation

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.

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.

I had the same issue on all env other than the base. Even installed the same version of traitlets, pygments and ipykernel as in base,it also failed. After a couple of searches, I removed traitlets using
sudo apt-get remove python3-traitlets
sudo apt-get remove --auto-remove python3-traitlets
Then I installed jupyter
conda install notebook ipykernel jupyterlab
This solved my issue on all environments

Related

The 'pyasn1-modules>=0.2.1' distribution was not found and is required by google-auth

I wanted to try Python's Geemap module, I installed it via conda install geemap -c conda-forge. But when importing it in my pyhton code I have this error message :The 'pyasn1-modules>=0.2.1' distribution was not found and is required by google-auth. So I updated pyasn1-modules, and now I have version 0.2.8 but the errors remains.
If someone has a idea...
Uninstall the version by conda and install the one by pip
conda remove --force pyasn1-modules
pip install pyasn1-modules
That solved the problem for me - although it doesn't make sense that it should!
Conda was the problem for me. Tried creating a new environment and installing everything with pip and that got rid of the error.

ImportError: No module named 'sklearn.compose' with scikit-learn==0.23.2

I'm fully aware of the previous post regarding this error. That issue was with scikit-learn < 0.20. But I'm having scikit-learn 0.23.2 and I've tried uninstall and reinstall 0.22 and 0.23 and I still have this error.
Followup: Although pip list told me the scikit-learn version is 0.23.2, but when I ran sklearn.__version__, the real version is 0.18.1. Why and how to resolve this inconsistency? (Uninstall 0.23.2 didn't work)
[RESOLVED]
It turned out that my Conda environment has different sys.path as my jupyter environment. The jupyter environment used the system env, which is due to the fact that I installed the ipykernel like this: python -m ipykernel install without use --user flag. The correct way should be to do so within the Conda env and run pip install jupyter

pip installed google.colab and now unable to run code on Jupyter notebook

I installed google.colab using pip install google.colab in my terminal, after doing this the jupyter notebook that I was working on stopped working. When I opened a new jupyter notebook, I could not run any code. When I tried to run any code it stayed stuck on In[*]. Before installing google.colab my notebooks were working fine. I tried restarting my kernel but that did not work. I also used pip uninstall google.colab but that gives the following: WARNING: Skipping google.colab as it is not installed. Then I tried uninstalling it by pip uninstall google-colab, which uninstalled it succesfully, but did not fix the issue.
I'm not sure if google.colab was the cause of not being able to run code on the jupyter notebook, but this happened immediately after the installation.
I have the following packages including version for jupyter
jupyter 1.0.0
jupyter-client 5.3.3
jupyter-console 6.0.0
jupyter-core 4.5.0
jupyterlab 1.1.4
jupyterlab-server 1.0.6
Can anyone help me? Thank you
If you have uninstalled collab thats good now you have to go to the anaconda prompt shell.
type in the command:
pip list --outdated
It will show you all the packages which are outdated on your PC.
Then close anaconda prompt shell and now go to windows powershell.( You can just search in the searchbox of taskbar. Run the windwos powershell and type this command:
pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}
This will take a while and you may see some red but after all the upgrades are done. Exit the powershell and restart anaconda and see if this works.
Just check your tornado or outdated version of some basic library. In my case these are like tornado, prompt-toolkit
Start notebook from terminal
Just check your terminal while notebook freeze at * once more
Now don't close anything
Just go to terminal from where you open notebook
Check which thread causing problem or library
Install or update that library.
It will help definitely. It works for me too
I just had the exact same problem and here is what I did to solve it.
It is caused by the fact that when you installed google.colab it required a lot of packages whose versions are significantly older than the current versions that's commonly used. So if you already have the newer version of those packages installed (and depended by jupyter), pip will actually uninstall your newer version and install the older version google.colab demanded. This bad behavior causes jupyter to fail.
pip install google.colab
...
ERROR: tensorboard 2.2.2 has requirement google-auth<2,>=1.6.3, but you'll have google-auth 1.4.2 which is incompatible.
Installing collected packages: portpicker, pandas, six, google-auth, tornado, simplegeneric, prompt-toolkit, ipython, ipykernel, idna, requests, notebook, google.colab
Attempting uninstall: pandas
Found existing installation: pandas 1.0.4
Uninstalling pandas-1.0.4:
Successfully uninstalled pandas-1.0.4
Attempting uninstall: six
Found existing installation: six 1.15.0
Uninstalling six-1.15.0:
Successfully uninstalled six-1.15.0
Attempting uninstall: google-auth
Found existing installation: google-auth 1.18.0
Uninstalling google-auth-1.18.0:
Successfully uninstalled google-auth-1.18.0
Attempting uninstall: tornado
Found existing installation: tornado 6.0.4
Uninstalling tornado-6.0.4:
Successfully uninstalled tornado-6.0.4
Attempting uninstall: prompt-toolkit
Found existing installation: prompt-toolkit 3.0.5
Uninstalling prompt-toolkit-3.0.5:
Successfully uninstalled prompt-toolkit-3.0.5
Attempting uninstall: ipython
Found existing installation: ipython 7.15.0
Uninstalling ipython-7.15.0:
Successfully uninstalled ipython-7.15.0
Attempting uninstall: ipykernel
Found existing installation: ipykernel 5.3.0
Uninstalling ipykernel-5.3.0:
Successfully uninstalled ipykernel-5.3.0
Attempting uninstall: idna
Found existing installation: idna 2.9
Uninstalling idna-2.9:
Successfully uninstalled idna-2.9
Attempting uninstall: requests
Found existing installation: requests 2.23.0
Uninstalling requests-2.23.0:
Successfully uninstalled requests-2.23.0
Attempting uninstall: notebook
Found existing installation: notebook 6.0.3
Uninstalling notebook-6.0.3:
Successfully uninstalled notebook-6.0.3
Successfully installed google-auth-1.4.2 google.colab idna-2.8 ipykernel-4.6.1 ipython-5.5.0 notebook-5.2.2 pandas-0.24.2 portpicker-1.2.0 prompt-toolkit-1.0.18 requests-2.21.0 simplegeneric-0.8.1 six-1.12.0 tornado-4.5.3
When you uninstalled the google.colab, those older version packages stayed. So the solution is to update those packages to their versions before you installed google.colab.
It is very simple:
Go to environment in Jupyter.
See in which environment notebook is not working/not output.
On the environment select environment which is not working.
Remove the environment.
Reinstall the required environment by directly adding the Python version you want; it takes around 5-10 minutes.

How can i solve the error with installing Jupyter?

I'm new to python , i tried to install jupyter by using this command
sudo pip install jupyter
but got
Found existing installation: tornado 3.1.1
Cannot uninstall 'tornado'. It is a distutils installed project and
thus we cannot accurately determine which files belong to it which
would lead to only a partial uninstall.
I got that there is more than one version of tornado but couldn't fix it
Thanks for any help
do pip uninstall tornado
and then
do pip install tornado==4.0.0

Best practice for `pip install` red warnings?

I have it many times that when installing with pip I get success messages followed by red lines with warnings. An example:
Successfully built qgrid
spacy 2.0.11 has requirement regex==2017.4.5, but you'll have regex 2017.11.9 which is incompatible.
proto-google-cloud-vision-v1 0.90.3 has requirement oauth2client<4.0dev,>=2.0.0, but you'll have oauth2client 4.1.2 which is incompatible.
proto-google-cloud-speech-v1beta1 0.15.3 has requirement oauth2client<4.0dev,>=2.0.0, but you'll have oauth2client 4.1.2 which is incompatible.
proto-google-cloud-spanner-v1 0.15.3 has requirement oauth2client<4.0dev,>=2.0.0, but you'll have oauth2client 4.1.2 which is incompatible.
How do I reconcile the state of the install in such cases? do these messages simply imply that older versions will be used so that the compatibility of previously installed packages will preserve? does it also imply that the newly installed package has requested newer versions and may or may not work well, with the old ones present?
How do you usually proceed in these cases?
Obviously working with virtual environments may remove the clashes, but I can see this happening also in virtual environments.
Thanks!
In these case, try :
py -m name_of_your_initial_package install --upgrade name_of_your_initial_package.
name_of_your_initial_package* example: proto-google-cloud-vision-v1
Full example :
py -m proto-google-cloud-vision-v1 install --upgrade proto-google-cloud-vision-v1
To do that you need to install your package with pip before :
py -m pip install proto-google-cloud-vision-v1

Categories