Assistance installing Jupyter Viewer xblock

I’m attempting to follow the instructions here to get this xblock running. Running as user tutor I did:

echo “git+https://github.com/ibleducation/jupyter-viewer-xblock.git” >> “$(tutor config printroot)/env/build/openedx/requirements/private.txt”

which seemed to go fine, and then I rebuilt the image. I then added "xblock_jupyter_viewer" to the module list but the xblock is not visible in my list of available advanced modules. This process has worked with other xblocks. What am I missing or what have I left out?

@qali may be of a help!

Hi @wjkowalski and @nachham ,

I belive that you may forgot to replace and install it ?

cd .local/share/tutor/env/build/openedx/requirements

git clone GitHub - iblai/jupyter-edx-viewer-xblock: View Jupyter Notebooks in Open edX

sudo rm -rf private.txt ( or edit if duplicated )

echo ’ -e ./jupyter-edx-viewer-xblock ’ >> private.txt

cd jupyter-edx-viewer-xblock

pip3 install -e . ( don’t forget the dot : )

tutor images build openedx

tutor local quickstart

Can you try this now ? Thanks…

Thank you @qali
I was able to complete these steps without errors but unfortunately I am still not seeing the Jupyter Xblock Viewer option in my advanced module settings. I don’t have a good enough understanding of the steps you gave above to determine where the problem might be. Do you have any thoughts?
Thanks

I got some import error due to compatibility, and trying to fix it. Did you get that also ?

for exemple : " urllib import urlencode" ?

Yes, I saw the same error during installation but it didn’t seem to stop anything so I didn’t report it.

I fixed it with editing " xblock_jupyter_viewer.py" file like this:

import logging

import pkg_resources
try:

    from urllib import urlencode

except ImportError:

    from urllib.parse import urlencode    

from django.urls import reverse

## from django.core.urlresolvers import reverse

from xblock.core import XBlock

from xblock.fields import Scope, String, Integer

from xblock.fragment import Fragment

from xblockutils.studio_editable import StudioEditableXBlockMixin

End finished without error.

But, now you must add this URL

Jupyter Viewer XBlock Endpoint

urlpatterns += (
url(r’^api/jupyter/', include(‘xblock_jupyter_viewer.rest.urls’,
namespace=‘xblock_jupyter_viewer’)),
)

to the =>

  • /edx/app/edxapp/edx-platform/lms/envs/common.py
  • /edx/app/edxapp/edx-platform/cms/envs/common.py

and it’s little bit complicated

I was able to locate xblock_jupyter_viewer.py and edit it to match your example (leaving the functions at the bottom which you did not mention) but after this I rebuilt the image and saw the message
cannot import name 'urlencode' from 'urllib'
although again the process seemed to finish. Now, however, I cannot even see the option for Advanced in my Modules. I didn’t change anything other than what you suggested so I’m not sure why you can see it and I can’t.

Please check indentation, save and rebuild again

tutor images build openedx

tutor local quickstart

May be you shuold try with a democourse ?

tutor local importdemocourse

By the way you should try my solutions, if you want to:

That’s full jupyter Hub, Lab, Notebook all works fine

I would like to try your solution for sure. I still need to find out what is wrong here though. Here is the error I am getting after implementing your suggestions and rebuilding the image.

I thought maybe my problem was just because I copied your lines above directly and realized they had curly quotes in them rather than plain ones, but it was not so simple.

Unable to load XBlock 'xblock_jupyter_viewer'
Traceback (most recent call last):
  File "/openedx/venv/lib/python3.8/site-packages/xblock/plugin.py", line 141, in load_classes
    yield (class_.name, cls._load_class_entry_point(class_))
  File "/openedx/venv/lib/python3.8/site-packages/xblock/plugin.py", line 70, in _load_class_entry_point
    class_ = entry_point.load()
  File "/openedx/venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/openedx/venv/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/openedx/venv/lib/python3.8/site-packages/xblock_jupyter_viewer/__init__.py", line 1, in <module>
    from .xblock_jupyter_viewer import JupyterViewerXBlock
  File "/openedx/venv/lib/python3.8/site-packages/xblock_jupyter_viewer/xblock_jupyter_viewer.py", line 5, in <module>
    from urllib import urlencode

ImportError: cannot import name 'urlencode' from 'urllib' (/opt/pyenv/versions/3.8.6/lib/python3.8/urllib/__init__.py)

I think to reason can be effekt this error:

from urllib.parse import urlencode

may be still exists ? that must be remove and replace the this one.

try:
    from urllib import urlencode
except ImportError:
    from urllib.parse import urlencode

But you already did it.
And the other thing is may be not enaugh place in HD ?

Hi @wjkowalski,
I forked the repo, and did some modifications, it seems working with Tutor plugin.

Please test it carefully, before using in production !
Installations guide in Readme file. I hope it works for you also.
Thanks

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.