Photo by Luis Cortés on Unsplash

Tips and tricks for Jupyter notebook issues

Swatimeena
2 min readAug 17, 2020

--

Everyone faces a lot of basic issues when they start with their coding and setting up the notebook remotely or locally, they are basic issues but takes a lot of our time while searching on the internet and due to the different OS everyone provides their solutions whatever works for them and we end up changing something in our OS environment libraries unknowingly. Here is something basic yet useful for notebook beginners.

Permission error while saving the jupyter notebook files or .py remotely

  1. Open terminal
  2. Login through ssh (ssh -X remote_username@remote_ip_address)
  3. Navigate to the working folder using cd command
  4. Check ls -ltrh in that folder path
    Check if the owner and group file is the root or your username
    If both are root, change it with chown command
  5. Run chown username folder name to change ownership
  6. Run chown username: username folder name to change both the ownership and group filename

Module import issues in Jupyter Notebook

  1. In terminal (If you are using an environment then activate the environment first),
  • Run
python
  • Then Run:
import sys
sys.executable
  • Copy the sys.executable path
  • Run the below command in new terminal window but in same environment or exit () in the running python and the run:
jupyter kernelspec list
  • Above command will show the available kernels.
  • Go the kernel path using cd command.
  • Run
open kernel.json
  1. In argv dictionary paste the path copied from sys.executable (replace the existing path)

Running jupyter notebook remotely

  1. Open terminal
  2. Login through ssh (ssh -X remote_username@remote_ip_address)
  3. Navigate to the working folder using cd command
  4. Run jupyter notebook — no-browser — port XXXX (any 4 digit number, 888X preferred like 8884)
  5. Open new local terminal
  6. Run ssh -NL XXXX:localhost:XXXX remote_username@remote_ip
  7. Open the browser in your system and run localhost:XXXX (use same port number everywhere)and enter token (mentioned in the remote terminal window, copy the token value and paste it in the browser)

--

--

Swatimeena

Data Scientist @Sprinklr | IIT Bombay | IIT (ISM) Dhanbad