Jupyter_contrib_nbextensions: New install failing ImportError: No module named 'yaml'

Created on 24 Apr 2016  路  32Comments  路  Source: ipython-contrib/jupyter_contrib_nbextensions

I have been having small issues with Jupyter (I have used and upgraded since very early days of IPython NB) I figured it was time to start fresh. and extensions so I went in and waxed all Jupyter and Ipython files I could find in bin and dist... I reinstalled Jupyter and the notebook came back fine and was running with no errors,, then I installed NB extensions with

 sudo pip3 install https://github.com/ipython-contrib/IPython-notebook-extensions/archive/master.zip --user --upgrade

And now on startup I get and I can't load the config page:
tom@tom-sam:~$ jupyter notebook /usr/local/lib/python3.4/dist-packages/widgetsnbextension/__init__.py:30: UserWarning: To use the jupyter-js-widgets nbextension, you'll need to update the Jupyter notebook to version 4.2 or later. the Jupyter notebook to version 4.2 or later.""") [W 08:24:02.477 NotebookApp] Error loading server extension nbextensions Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/notebook/notebookapp.py", line 1042, in init_server_extensions mod = importlib.import_module(modulename) File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 2254, in _gcd_import File "<frozen importlib._bootstrap>", line 2237, in _find_and_load File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked File "<frozen importlib._bootstrap>", line 1129, in _exec File "<frozen importlib._bootstrap>", line 1471, in exec_module File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed File "/home/tom/.local/share/jupyter/extensions/nbextensions.py", line 21, in <module> import yaml ImportError: No module named 'yaml'

To boot I confirm that notebook is at 4,2

jupyter-notebook --version
4.2.0

Most helpful comment

Hi there. Sorry to hear you're having problems. I'm afraid that installation is the biggest problem we have with this repo at the moment, lots of problems many and various. On the plus side, it looks like most the installation has gone ok, and you're just missing the yaml dependency for some reason (our dependency lists are somewhat patchy, and in several places, I think this particular issue results from yaml missing from setup.py dependencies).

Hopefully, this should be fixed by issuing

pip install pyyaml

(or, in your case, presumably sudo pip3 install pyyaml)

All 32 comments

FWIW the bulk of issues seem to have started with the install of the IPywidgets 5 which also were/are auto installed by the NB extensions now, wondering if an install I did previously on pip (python2) vs a subsequent pip3 install since Jupyter is running via a pip3 install.. could be some part of the problem? but don't see any evidence of it?

Hi there. Sorry to hear you're having problems. I'm afraid that installation is the biggest problem we have with this repo at the moment, lots of problems many and various. On the plus side, it looks like most the installation has gone ok, and you're just missing the yaml dependency for some reason (our dependency lists are somewhat patchy, and in several places, I think this particular issue results from yaml missing from setup.py dependencies).

Hopefully, this should be fixed by issuing

pip install pyyaml

(or, in your case, presumably sudo pip3 install pyyaml)

(The yaml python package is provided by the PyYAML pip package)

on closer inspection, it seems that setup.py _does_ actually specify pyyaml as a requirement, so I'm not really sure why it hasn't been installed in your case...

Sorry but it is installed so I have no idea why it is not being found..!

Hmm. Curiouser and curiouser. OK, so to clarify, could you let me know:

  • whether you run jupyter as python3 jupyter notebook or similar?
  • what happens if you try import yaml from a python3/ipython3 prompt?

also:

  • what which jupyter gives
  • what which jupyter-notebook gives

1) I normally just do >>jupyter notebook
2)From in a p3 notebook I get no module named yaml when doing 'import yaml'
3) same from a p3 shell
4)which jupyter goves /usr/local/bin/jupyter
5)which jupyter-notebook gives /usr/local/bin/jupyter-notebook

Very weird that yaml won't import seems something messed up with base p3? any ideas?

Very odd. And

pip show pyyaml

shows it to be installed?

If you're on a system using apt, you might try the suggestion in this comment: https://github.com/ipython-contrib/IPython-notebook-extensions/issues/304#issuecomment-169483106

And, to clarify what python is getting used for jupyter, what do you get for head -1which jupyterand `head -1 `which jupyter-notebook? (I'm thinking of shebang lines, but I'd expect them to point to the python used for the most recently installed jupyter)

Are you using any virtual environments?

very strange pip3 show pyyaml just returns to command prompt then using pip3 list I don't see any pyyaml (or yaml)
Not using vitrual env :-(
tom@tom-sam:~$ head -1 which jupyter

!/usr/bin/python3

tom@tom-sam:~$ head -1 which jupyter-notebook

!/usr/bin/python3

OK, and what does the pip3 install pyyaml give? If pip3 is claiming simultaneously to have installed pyyaml but also not showing it as installed, then I think this is more of a pip problem!

hunh pip3 just uninstalled PyYAML and reinstalled and that fixed that one!

hahaha ok! So probably an issue somewhere with pyyaml and/or pip...

and now have the nbextensions page! Thanks for all the help!

no worries, you're welcome 馃槃

still getting this erroneous warning but don't think it is bad? /usr/local/lib/python3.4/dist-packages/widgetsnbextension/init.py:30: UserWarning: To use the jupyter-js-widgets nbextension, you'll need to update
the Jupyter notebook to version 4.2 or later.
the Jupyter notebook to version 4.2 or later.""")

yeah, that seems strange, given you seem to be running 4.2 already anyway... It doesn't sound like a problem, and as far as I'm aware, it's not used by anything in this repo anyway. Based on the experience with pyyaml, you might try a
pip uninstall/resintall of ipywidgets... 馃槅

You might want to check your kernelspec. Juyper loads the Python version defined there:

hasch@VirtualMint ~ $ jupyter kernelspec list
Available kernels:
  python3    /home/hasch/.local/share/jupyter/kernels/python3

hasch@VirtualMint ~ $ cat ~/.local/share/jupyter/kernels/python3/kernel.json 
{
 "language": "python",
 "argv": [
  "/home/hasch/anaconda3/bin/python",
  "-m",
  "ipykernel",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Python 3"

This often leads to confusion. I usually remove the absolute path and only use python

The warning about updating to jupyter 4.2 seems to fire regardless of the actually installed version, as noted in #591

closing this, as it seems it was resolved ok.

For followers, I was able to work around this by doing a "conda activate xx" first, then it worked.

pip install pyyaml

Requirement already satisfied: pyyaml in /home/ad/venv/lib/python3.5/site-packages (3.13)

still fetching same problem

File "/tmp/easy_install-Q6yl7W/models-0.9.3/setup.py", line 25, in
File "/tmp/easy_install-Q6yl7W/models-0.9.3/models/__init__.py", line 24, in
File "/tmp/easy_install-Q6yl7W/models-0.9.3/models/props.py", line 23, in
ImportError: No module named yaml

the issue got resolved for centos using below command.

pip install PyYAML

I solve it by
pip install pyyaml==5.1.0
the newest is 5.3.0, it doesn't work

pip install pyyaml --ignore-installed did the trick.

pip install pyyaml --ignore-installed did the trick.

Thanks. I've tried the install pyaml method and got the same error. This fix did the trick for me.

for me, none of it works;

``` $ pip freeze
python-dateutil==2.8.1
PyYAML==5.3.1
ruamel.yaml==0.16.12
ruamel.yaml.clib==0.2.2
six==1.15.0
strictyaml==1.1.1

but when I run my script:
import yaml

ModuleNotFoundError: No module named 'yaml'
```

I have the exact same issue as jurgenweber. I also tried pip uninstall pyymal to uninstall v5.3.1 and running pip install PyYAML==5.1.0 as per starxchina's suggestion, but that didn't seem to make a difference. I also tried v3.13, but even that old of a version didn't seem to work for me. I'm trying this on Windows.

@MyNameIsTrez I eventually got it to work, but I am unsure what did it. I think just opening up in a new shell was part of it, it was all very weird and frustrating on Friday. :0

@jurgenweber That didn't fix the issue for me in VS Code's shell, but let's hope it works for someone else.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

okdolly-001 picture okdolly-001  路  3Comments

ruxi picture ruxi  路  6Comments

Hgh2017 picture Hgh2017  路  3Comments

metabolinguistics picture metabolinguistics  路  4Comments

ggrrll picture ggrrll  路  7Comments