Open a Jupyter notebook within running server from command line - python

My Jupyter/IPython notebooks reside in various directories all over my file system. I don't enjoy navigating hierarchies of directories in the Jupyter notebook browser every time I have to open a notebook. In absence of the (still) missing feature allowing to bookmark directories within Jupyter, I want to explore if I can open a notebook from the command line such that it is opened by the Jupyter instance that is already running. I don't know how to do this....

Option 1: Run multiple jupyter notebook servers from your project directory root(s). This avoids navigating deeply nested structures using the browser ui. I often run many notebook servers simultaneously without issue.
$ cd path/to/project/; jupyter notebook;
Option 2: If you know the path you could use webbrowser module
$ python -m webbrowser http://localhost:port/path/to/notebook/notebook-name.ipynb
Of course you could alias frequently accessed notebooks to something nice as well.

Related

Share with anyone on the web interactive python jupyter notebook with dependent files and functions in another file (.py): Colab or something else?

What are the free solutions for sharing an interactive python Jupyter notebook with user-defined module and dependent input files?
I have python Jupyter notebook that serves as a code interface for non-technical users. The code itself is in another file code.py that contains many functions that are called from the python Jupyter notebook as needed. Running these functions reqires about ten input files with a size of 100 mb. I want anyone on the web to open this notebook in an executable environment such that the user can run the code with different user choices.
One approach I consider implementing is to use Google Colab, Google Drive, GitHub, and
the Python Package Index (PyPI) as follows:
Package the code.py as PyPI module
Add dependent input files on Google Drive and get their shared link id
Add Colab notebook on GitHub
Once the user run the Colab notebook then it will pip install and import the functions on code.py and download the dependent input files from Google Drive
How to improve or simplify this approach?
What would be a better Colab-based approach to do this job?
Is there any other environments (e.g., Binder) that are more suitable than Colab for this job ?
You can use MyBinder.org and use curl or wget in a postBuild or start configuration file to get your input files if they are elsewhere.
For non-technical users you may want to combine in the use of Voila and myBinder.org. See here about Voila. There's a launch binder badge you can use to demo there. There's a bunch of other examples that run on MyBinder at the Voila Gallery, too.

How to directly open Jupyter from cmd instead of copying link

I often use jupyter for classes, and use the commmand python -m notebook to open the notebook. The tab that opens up shows an error, and then I have to copy one of the links in the terminal window instead. Is there a way or a command that I can use so that one of those links automatically opens up?
NOTE: It opens the file location (first address in the picture) and fails, and I use the links below to open jupyter. I want the terminal to open the links directly if possible to save time.
This is the error that I get.
jupyter notebook notebook.ipynb
Taken from this documentation.
It shouldn't matter whether you install it using conda or pip.
Or you can just type jupyter notebook which should open up a your file directory in the browser and let you navigate to the notebook file you want to open.
Edit: For this error, it really is hard without knowing the full context of the commands you are running, the directory you are calling from, and where this file you want to open is located. Make sure you are in the folder that contains your notebook file. If not, you should specify the entire path to the notebook file. Finally, does the command jupyter notebook by itself work?

Open .ipynb in Anaconda Jupyter Notebook on double-click (macOS)

I've been trying to figure out how I can open a .ipynb file on double-click on a Mac, so the file opens with Anaconda and then automatically opens Jupyter Notebook with the file contents.
I have tried creating an application through Automator that opens with a jupyter_lab command, but the issue is that Jupyter lives in Anaconda, so this method is not working. See these articles for my steps: https://samedwardes.com/2020-01-31-open-ipynb-with-double-click/ and Open an ipython notebook via double-click on osx
I have also tried installing nbopen with the following:
python3 -m pip install nbopen
This works, and then I can run nbopen file.ipynb through the terminal, but I want to be able to bypass this step and do it while in file explorer, physically looking at the file instead.
I have ran the recommended command for osx to integrate it with file manager ./osx-install.sh but I just get zsh no such file or directory and can't really find any help with figuring out why this is pushing back an error.
Any suggestions?
I have this "convenience issue" as well, and didn't go for the nbopen route, but instead, I just made a batch script (I named it jupyter-notebook.bat) that calls certain conda functions, and pretty much initiates things like how double clicking works. In the script, I just have this:
call "C:\Users\XYZ\Anaconda3\Scripts\activate.bat"
call conda activate myEnvironment
call python C:\Users\XYZ\Anaconda3\Scripts\jupyter-notebook-script.py %1
Lastly you just need to configure that every .ipynb opens up using your jupyter-notebook.bat script.
For consistency, I placed the script in my Anaconda folder. And if you also have nb_conda_kernels installed in your base environment, you'd have access to the other environment you've created as well from there.

Jupyter -- opening notebooks on mac

This is a bit hard to explain so bear with me! Suppose I have a Jupyter notebook in some directory. The only way I know to open it is to click repeatedly through the web based directory structure. Is there a nice way to do this using the mac finder. In other words I would like a simple dialogue box to open from Jupyter to navigate to my notebook.
edit: thanks, I realized that I can start in certain directories, but what if I'm opening a bunch of different notebooks from different directories. It sure would be nice to be able to jump to my favorites easily.
As #GiantsLoveDeathMetal mentions... if you navigate to a specific directory in your terminal and then type jupyter notebook the notebook will open and display in your browser, just the content of that folder.
For example:
$ cd /path/to/the/folder/with/your/notebook.ipynb
$ jupyter notebook

Ipython installation - creating nbserver profile - missing notebook_config.py file

I am trying to use the guidance on http://www.slideshare.net/fullscreen/randyzwitch/ipython-ec2/12 to install public Ipython notebooks in an AWS instance. One problem that i encounter is, when i try to create a profile, i do not not observe the creation of an ipython_notebook_config_py file (as explained in the tutoral, as per the screenshot), but i only get a ipython_kernel_config.py file, which has very different contents, and cannot be edited in the way as explained in the tutoral. Can someone help me to understand why this happens, and what i should do subsequently? Many thanks.
The notebook server is no longer part of IPython; it's a separate Jupyter project, which has its own config directory ~/.jupyter. The config file for the notebook server is ~/.jupyter/jupyter_notebook_config.py. You can use this to configure the notebook server. If you want to keep multiple configurations of the notebook server, you can use the environment variable JUPYTER_CONFIG_DIR to specify that a different directory should be used:
JUPYTER_CONFIG_DIR=~/jupyter_nbserver jupyter notebook
Note: IPython has not lost its profiles or config files, so ~/.ipython/profile_default/ipython_config.py and startup files, etc. continue to work as before for configuring the IPython kernel, just not the notebook server itself.
References:
Running a public notebook server
Jupyter configuration
Migration from IPython to Jupyter

Categories

Resources