How to pip install in JupyterLab

Do you now how to install numpy or any package to Yunohost JupiterLab venv environment?

When I use pip I get the following error:


Thanks for your help!

I have never used JupyterLab in YNH, but in Anaconda distribution I use a Console window, not a Notebook. Go like you would create a new Notebook, but select Console. Then type in your command, without the prepended !.

Thanks @tituspijean for the reply.
I get the same error with the console… :

OK then, try this in command line:

cd /opt/jupyterlab
pipenv shell
pip install numpy

:crossed_fingers:

Edit: confirmed working on my virtual machine:

 ⚡ root@vm > ~ > cd /opt/jupyterlab
 ⚡ root@vm > /opt/jupyterlab > pipenv shell
Launching subshell in virtual environment…
 . /opt/jupyterlab/.venv/bin/activate
 ⚡ root@vm > /opt/jupyterlab >  . /opt/jupyterlab/.venv/bin/activate
(jupyterlab)  ⚡ root@vm > /opt/jupyterlab > pip install numpy
Collecting numpy
  Downloading numpy-1.18.2-cp35-cp35m-manylinux1_x86_64.whl (20.0 MB)
     |████████████████████████████████| 20.0 MB 1.1 MB/s
Installing collected packages: numpy
Successfully installed numpy-1.18.2
(jupyterlab)  ⚡ root@vm > /opt/jupyterlab >

Thanks again @tituspijean, but I still get the same error about permission denied…

ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission non accordée: '/opt/jupyterlab/.venv/lib/python3.5/site-packages/numpy-1.18.2.dist-info' Consider using the–user option or check the permissions.

Which user are you running the command with?
Can you show which user the folder belongs to? ls -la /opt/jupyterlab

Please show all the commands you are using to get to the error. A copy/paste of your screen would be perfect.

One thing, maybe try to install numpy system-wide. exit the virtualenv first, then run pip install numpy

My console output :

admin@ericg:~$ cd /opt/jupyterlab
admin@ericg:/opt/jupyterlab$ pipenv shell
Launching subshell in virtual environment…
admin@ericg:/opt/jupyterlab$  . /opt/jupyterlab/.venv/bin/activate
(jupyterlab) admin@ericandmarie:/opt/jupyterlab$ pip install numpy
Collecting numpy
  Using cached numpy-1.18.2-cp35-cp35m-manylinux1_x86_64.whl (20.0 MB)
Installing collected packages: numpy
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission non accordée: '/opt/jupyterlab/.venv/lib/python3.5/site-packages/numpy-1.18.2.dist-info'
Consider using the `--user` option or check the permissions.
admin@eg:/opt/jupyterlab$ ls -la
total 132
drwxr-xr-x 4 root root   4096 mars  31 14:11 .
drwxr-xr-x 6 root root   4096 mars  19 17:15 ..
drwxr-xr-x 2 root root   4096 mars  27 20:35 config
-rw------- 1 root root     65 mars  19 17:16 jupyterhub_cookie_secret
-rw-r--r-- 1 root root      4 mars  27 20:35 jupyterhub-proxy.pid
-rw-r--r-- 1 root root 102400 mars  31 14:11 jupyterhub.sqlite
-rw-r--r-- 1 root root    228 mars  24 15:49 Pipfile
drwxr-xr-x 7 root root   4096 mars  24 15:49 .venv
admin@ericg:/opt/jupyterlab$ cd
admin@ericg:~$ pip install numpy
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

OK the difference between my VM and your server is that I run as root, you as admin, and my jupyterlab folder belongs to admin and yours to root.

Try:

chown -R admin: /opt/jupyterlab
cd /opt/jupyterlab
pipenv shell
pip install numpy

As to why your directory does not belong to the same user, I don’t know.

Edit post-solution:
The matter is also discussed on Github: jupyterlab_ynh #35

There may be issues with multi-users with my solution.

2 Likes

:100: succes!
Thank you for your help @tituspijean

1 Like

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