3

Issue as in title.

I am trying to get Jupyter notebooks running python remotely on my work computer (far better resources than my personal machine).

I think the issue may be originating from how something in the environment is set up (Linux), but I have been troubleshooting for over a day now and could really do with some help.

I am using a virtual environment, and had some issues with getting it to use the jupyter executable in my virtual environment. I have now resolved this. I have installed the venv as a kernel and can run on this in the notebook (A) or I can launch the notebook explicitly using the venv executable (B). However there is still an inconsistency between python paths of which and sys.executable:

In terminal (venv active):

(venv) npc8.pauln> which python 
/home/pauln/wtf/venv/bin/python
(venv) npc8.pauln> python
Python 3.6.8 (default, Apr  2 2020, 13:34:55) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/home/pauln/wtf/venv/bin/python'

Jupyter (identical in the cases of A and B described above):

! which python

/bin/python

import sys

sys.executable

'/home/pauln/wtf/venv/bin/python3'

As a sanity check, I replicated the above on my home machine - both return the same value, as I think would be expected. I also noted that if I start a terminal from within the notebook, it does not enter the venv by default on my work machine, but it does on my home machine.

I also checked jupyter-troubleshoot, and include it incase it is useful:

Terminal (venv active):

(venv) npc8.pauln> jupyter-troubleshoot
WARNING: You are using pip version 20.2.2; however, version 20.2.4 is available.
You should consider upgrading via the '/home/pauln/wtf/venv/bin/python -m pip install --upgrade pip' command.
$PATH:
        /home/pauln/wtf/venv/bin
        /w/work3/home/pauln/TeXLive/2020/bin/x86_64-linux
        /mnt/share/cern_CentOS7/root/v6.20.04/bin
        ./
        /bin
        /usr/bin
        /usr/local/bin
        /home/pauln/apps/clas12root/bin
        /home/pauln/apps/chanser/bin

sys.path:
        /home/pauln/wtf/venv/bin
        /mnt/share/cern_CentOS7/root/v6.20.04/lib
        /home/pauln/wtf
        /usr/lib64/python36.zip
        /usr/lib64/python3.6
        /usr/lib64/python3.6/lib-dynload
        /home/pauln/wtf/venv/lib64/python3.6/site-packages
        /home/pauln/wtf/venv/lib/python3.6/site-packages

sys.executable:
        /home/pauln/wtf/venv/bin/python

sys.version:
        3.6.8 (default, Apr  2 2020, 13:34:55) 
        [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

platform.platform():
        Linux-3.10.0-1127.19.1.el7.x86_64-x86_64-with-centos-7.8.2003-Core

which -a jupyter:
        /home/pauln/wtf/venv/bin/jupyter
        /usr/local/bin/jupyter

pip list:
        Package             Version
        ------------------- ---------
        argon2-cffi         20.1.0
        async-generator     1.10
        attrs               20.3.0
        awkward             0.14.0
        backcall            0.2.0
        bleach              3.2.1
        cachetools          4.1.1
        certifi             2020.11.8
        cffi                1.14.3
        cycler              0.10.0
        decorator           4.4.2
        defusedxml          0.6.0
        entrypoints         0.3
        importlib-metadata  2.0.0
        ipykernel           5.3.4
        ipython             7.16.1
        ipython-genutils    0.2.0
        ipywidgets          7.5.1
        jedi                0.17.2
        Jinja2              2.11.2
        jsonschema          3.2.0
        jupyter             1.0.0
        jupyter-client      6.1.7
        jupyter-console     6.2.0
        jupyter-core        4.6.3
        jupyterlab-pygments 0.1.2
        kiwisolver          1.3.1
        MarkupSafe          1.1.1
        matplotlib          3.3.2
        mistune             0.8.4
        nbclient            0.5.1
        nbconvert           6.0.7
        nbformat            5.0.8
        nest-asyncio        1.4.2
        notebook            6.1.5
        numpy               1.19.4
        packaging           20.4
        pandas              1.1.4
        pandocfilters       1.4.3
        parso               0.7.1
        pexpect             4.8.0
        pickleshare         0.7.5
        Pillow              8.0.1
        pip                 20.2.2
        prometheus-client   0.8.0
        prompt-toolkit      3.0.8
        ptyprocess          0.6.0
        pycparser           2.20
        Pygments            2.7.2
        pyparsing           2.4.7
        pyrsistent          0.17.3
        python-dateutil     2.8.1
        pytz                2020.4
        pyzmq               19.0.2
        qtconsole           4.7.7
        QtPy                1.9.0
        Send2Trash          1.5.0
        setuptools          49.6.0
        six                 1.15.0
        terminado           0.9.1
        testpath            0.4.4
        tornado             6.1
        traitlets           4.3.3
        uproot              3.13.0
        uproot-methods      0.8.0
        wcwidth             0.2.5
        webencodings        0.5.1
        wheel               0.35.1
        widgetsnbextension  3.5.1
        zipp                3.4.0

From notebook (again A and B):

WARNING: You are using pip version 19.3.1; however, version 20.2.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$PATH:
    /mnt/share/cern_CentOS7/root/v6.20.04/bin
    ./
    /bin
    /usr/bin
    /usr/local/bin
    /home/pauln/apps/clas12root/bin
    /home/pauln/apps/chanser/bin
    /w/work3/home/pauln/TeXLive/2020/bin/x86_64-linux

sys.path:
    /mnt/share/local_CentOS7/bin
    /mnt/share/cern_CentOS7/root/v6.20.04/lib
    /home/pauln/wtf
    /usr/local/lib/python37.zip
    /usr/local/lib/python3.7
    /usr/local/lib/python3.7/lib-dynload
    /usr/local/lib/python3.7/site-packages

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

sys.version:
    3.7.0 (default, Sep 17 2018, 10:25:45) 
    [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

platform.platform():
    Linux-3.10.0-1127.19.1.el7.x86_64-x86_64-with-centos-7.8.2003-Core

which -a jupyter:
    /usr/local/bin/jupyter

pip list:
    Package            Version 
    ------------------ --------
    attrs              19.3.0  
    backcall           0.1.0   
    bleach             3.1.0   
    corner             2.0.1   
    cycler             0.10.0  
    Cython             0.29.6  
    decorator          4.4.1   
    defusedxml         0.6.0   
    emcee              2.2.1   
    entrypoints        0.3     
    importlib-metadata 0.23    
    ipykernel          5.1.3   
    ipython            7.9.0   
    ipython-genutils   0.2.0   
    ipywidgets         7.5.1   
    jedi               0.15.1  
    Jinja2             2.10.3  
    jsonschema         3.1.1   
    jupyter            1.0.0   
    jupyter-client     5.3.4   
    jupyter-console    6.0.0   
    jupyter-core       4.6.1   
    kiwisolver         1.0.1   
    MarkupSafe         1.1.1   
    matplotlib         3.0.3   
    mistune            0.8.4   
    more-itertools     7.2.0   
    nbconvert          5.6.1   
    nbformat           4.4.0   
    notebook           6.0.2   
    numpy              1.17.4  
    pandas             0.25.3  
    pandocfilters      1.4.2   
    parso              0.5.1   
    pexpect            4.7.0   
    pickleshare        0.7.5   
    pip                19.3.1  
    prometheus-client  0.7.1   
    prompt-toolkit     2.0.10  
    ptyprocess         0.6.0   
    Pygments           2.4.2   
    pymc               2.3.6   
    pyparsing          2.3.1   
    pyrsistent         0.15.5  
    pystan             2.18.1.0
    python-dateutil    2.8.1   
    pytz               2019.3  
    pyzmq              18.1.0  
    qtconsole          4.4.3   
    root-numpy         4.8.0   
    root-pandas        0.7.0   
    Send2Trash         1.5.0   
    setuptools         41.6.0  
    six                1.13.0  
    terminado          0.8.2   
    testpath           0.4.4   
    tornado            6.0.3   
    traitlets          4.3.3   
    wcwidth            0.1.7   
    webencodings       0.5.1   
    widgetsnbextension 3.5.1   
    zipp               0.6.0

Any help would be greatly appreciated!

Cheers, Paul

Paidoo
  • 379
  • 3
  • 13
  • 1
    Hi, try the answer [here](https://stackoverflow.com/questions/65373063/sys-path-and-sys-executable-is-incorrect-in-jupyter-but-no-applied-fix-is-worki/65798637#65798637) – Aidas Liaudanskas Jan 19 '21 at 20:03

0 Answers0