jupyterlab / extension-examples

JupyterLab Extensions by Examples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hello World - Extension Build Issue

jigarpthakkar opened this issue · comments

commented

Description

I am new to JupyterLab (and AI/ML, Python arena). I want to do some experiments with JupyterLab and intend to develop an extension. I have started with JypterLab installation and running "hello-world" extension on JypterLab.

When I tried to build (pip install -e .) "hello-world" (https://github.com/jupyterlab/extension-examples/tree/master/hello-world) extension generated using cookiecutter, there is an error saying "ModuleNotFoundError: No module named 'jupyterlab'"

It looks like, while compile extension, code tries to access juypterlab package but not able to find it.

I tried to search already opened issues, but could not find if someone has already faced such issue before. So I think I have missed something obvious. Please do advice or point me to a direction. Thank you.

Reproduce

I have followed steps given on "hello-world" example - https://github.com/jupyterlab/extension-examples/tree/master/hello-world

  1. Generated hello-world extension using cookiecutter.
  2. Then tried to build the extension using "pip install -e ."

At this build I am facing below error.

> dss-hello-world@0.1.0 install:extension
> jlpm run build

Traceback (most recent call last):
  File "/home/dc-user/.local/bin/jlpm", line 5, in <module>
    from jupyterlab.jlpmapp import main
ModuleNotFoundError: No module named 'jupyterlab'

Expected behavior

Extension build should be successful

Context

  • Operating System and version: Oracle Linux 7.9
  • Browser and version:
  • JupyterLab version: jupyter --version (output is as below)
    IPython : 8.0.1
    ipykernel : 6.7.0
    ipywidgets : not installed
    jupyter_client : 7.1.1
    jupyter_core : 4.9.1
    jupyter_server : 1.13.3
    jupyterlab : 3.2.8
    nbclient : 0.5.10
    nbconvert : 6.4.0
    nbformat : 5.1.3
    notebook : 6.4.7
    qtconsole : not installed
    traitlets : 5.1.1
Troubleshoot Output
$PATH:
	$HOME/.local/bin
	$HOME/.nvm/versions/node/v16.13.2/bin
	/usr/local/sbin
	/usr/sbin
	/sbin
	/usr/local/bin
	/usr/bin
	$HOME/.local/bin
	$HOME/bin

sys.path:
$HOME/.local/bin
/usr/local/lib/python39.zip
/usr/local/lib/python3.9
/usr/local/lib/python3.9/lib-dynload
/home/dc-user/.local/lib/python3.9/site-packages
/usr/local/lib/python3.9/site-packages
/home/dc-user/ws/dss_hello_world

sys.executable:
/usr/local/bin/python3.9

sys.version:
3.9.9 (main, Jan 19 2022, 05:29:44)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44.0.3)]

platform.platform():
Linux-3.10.0-1127.el7.x86_64-x86_64-with-glibc2.17

which -a jupyter:
$HOME/.local/bin/jupyter
$HOME/.local/bin/jupyter

pip list:
Package Version Editable project location
-------------------- --------- --------------------------------
anyio 3.5.0
argon2-cffi 21.3.0
argon2-cffi-bindings 21.2.0
arrow 1.2.1
asttokens 2.0.5
attrs 21.4.0
Babel 2.9.1
backcall 0.2.0
binaryornot 0.4.4
black 21.12b0
bleach 4.1.0
certifi 2021.10.8
cffi 1.15.0
chardet 4.0.0
charset-normalizer 2.0.10
click 8.0.3
cookiecutter 1.7.3
debugpy 1.5.1
decorator 5.1.1
defusedxml 0.7.1
dss-hello-world 0.1.0 $HOME/ws/dss_hello_world
entrypoints 0.3
executing 0.8.2
idna 3.3
ipykernel 6.7.0
ipython 8.0.1
ipython-genutils 0.2.0
jedi 0.18.1
Jinja2 3.0.3
jinja2-time 0.2.0
json5 0.9.6
jsonschema 4.4.0
jupyter-client 7.1.1
jupyter-core 4.9.1
jupyter-server 1.13.3
jupyterlab 3.2.8
jupyterlab-pygments 0.1.2
jupyterlab-server 2.10.3
MarkupSafe 2.0.1
matplotlib-inline 0.1.3
mistune 0.8.4
mypy-extensions 0.4.3
nbclassic 0.3.5
nbclient 0.5.10
nbconvert 6.4.0
nbformat 5.1.3
nest-asyncio 1.5.4
notebook 6.4.7
packaging 21.3
pandocfilters 1.5.0
parso 0.8.3
pathspec 0.9.0
pexpect 4.8.0
pickleshare 0.7.5
pip 21.3.1
platformdirs 2.4.1
poyo 0.5.0
prometheus-client 0.12.0
prompt-toolkit 3.0.24
ptyprocess 0.7.0
pure-eval 0.2.1
pycparser 2.21
Pygments 2.11.2
pyparsing 3.0.6
pyrsistent 0.18.1
python-dateutil 2.8.2
python-slugify 5.0.2
pytz 2021.3
pyzmq 22.3.0
requests 2.27.1
Send2Trash 1.8.0
setuptools 58.1.0
six 1.16.0
sniffio 1.2.0
stack-data 0.1.4
terminado 0.12.1
testpath 0.5.0
text-unidecode 1.3
tomli 1.2.3
tornado 6.1
traitlets 5.1.1
typing_extensions 4.0.1
urllib3 1.26.8
wcwidth 0.2.5
webencodings 0.5.1
websocket-client 1.2.3

Command Line Output
Paste the output from your command line running `jupyter lab` here, use `--debug` if possible.
Browser Output
Paste the output from your browser Javascript console here, if applicable.

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Hey @jigarpthakkar do you have multiple python installed on your computer? It looks you are hitting some kind of mixed environments issue.

I would strongly encourage you to use a virtual environment with conda or Python virtual env

commented

Hi @fcollonval , Thank you for your prompt response. Sure let me try with Python virtual environment and will update if the issue is resolved.

Best regards,
Jigar.

commented

Hi @fcollonval ,

I have used Python virtual env, and now I am able to successfully run

pip install -e .

Thanks to you :).

However, when I ran (note that my venv is active)

jupyter labextension develop . --overwrite

First it gave me

PermissionError: [Errno 13] Permission denied: '/usr/local/share/jupyter'

And when I ran it with sudo

sudo jupyter labextension develop . --overwrite

It gave me following error

(env) [user@host dss_hello_world]$ sudo jupyter labextension develop . --overwrite
Traceback (most recent call last):
  File "/home/user/.local/bin/jupyter", line 5, in <module>
    from jupyter_core.command import main
ModuleNotFoundError: No module named 'jupyter_core'

Should this jupyter command run from env? Because I see it is being ran from .local/bin? Any tips to resolve this issue?

Thanks.

Hey it needs to be run from the virtual env. Butt this is strange that it takes to write into /usr. It should be writing into the virtual env.
I'm afak right now but I can copy paste a substitute for that command - it creates a link from your dev folder to the JupyterLab share folder.

commented

No problem, Thank you. Meanwhile, I will try to find a way to make it work.

So you need to run in your virtual environment:

$ jupyter labextension list
JupyterLab v3.2.5
/path/to/venv/share/jupyter/labextensions
        jupyterlab-plotly v5.4.0 enabled OK
        @jupyter-widgets/jupyterlab-manager v3.0.1 enabled OK (python, jupyterlab_widgets)

The important part to figure out is the share/jupyter/labextensions folder.

Then if your extension is named jupyterlab-myextension, instead of running jupyter labextension develop . --overwrite you can create a symlink between the jupyterlab_myextension/labextension dev folder and /path/to/venv/share/jupyter/labextensions/jupyterlab-myextension (the name must be identical to the name mentioned in the package.json).

commented

Hi @fcollonval , I could address the issue by installing jupyter_core. I also removed and recreated virtual environment. Thank you so much for your help. I appreciate it.

Best regards,
Jigar.