In this post, I am going to go through some initial steps for people who are looking to try out Jupyter Notebooks (JN). We will see how to:
- Use a venv in our Jupyter notebook to work on projects.
- Shortcuts for working with JN.
- Basic ways of using new python shortcuts provided in IPython.
Que. How to install IPython inside a virtualenv and use it?
Ans: These are a few ways to launch the python installed in your venv
- venv/bin/ipython
- python -m IPython
Que. How to use the venv as a kernel for your Jupyter Notebook.
Step 1: Install the package:
pip install ipykernel
Step 2: Activate venv : source venv/bin/activate
Step 3: Add the venv to kernel.
ipython kernel install --name "venv"
Step 4: Launch Jupyter notebook
Step 5: Create a new notebook with the "venv" kernel.
Que: How to check all kernels available in your jupyter notebook?
Ans: Use this command (in the terminal)
jupyter kernelspec list
Result:
jupyter kernelspec remove venv
Que: How to edit a kernel display name?
Using the list command (shown above) , locate the kernel location you want to rename.
Edit the file> kernel.json and change the display_name property as per your liking.
After saving above file, relaunch jupyter notebook and try to create a new notebook.
Using Jupyter Notebook. Essentials KB Shortcuts, commands.
- Help on something: whatever?
(Whatever can be variable?, function?, object.property?, object.method? etc.
-
More Help: whatever??
This can even show the source code. -
Finding anything if we don't have an exact idea using wildcard matching.
Below are few valid examples:
Shortcuts for working with Jupyter interface
- Edit Mode (of a cell) : Green color:
- Edit Row (add above, add below, cut) : Blue Color
- Switch from editing a cell/row to vice-versa: Esc Key
- Add Row Above (In "Edit Row" mode): A
- Add Row Below (In "Edit Row" mode): B
Magic commands:
- Paste a copied code: %paste
- Choose exception mode: %xmode [Plain, Verbose, Context]
See History:
- All history: %history
- History for lines: %history -n -l 4 (-n is to show line numbers too).
No comments:
Post a Comment