Open .ipynb in browser from command line - ipython

How do I open a .ipynb file in the browser from the command line?
I've tried:
$ jupyter my_notebook.ipynb
But I get the cryptic:
Error executing Jupyter command 'my_notebook.ipynb': [Errno 2] No such file or directory
It's weird because that file exists (and is readable) as named.
I'm running:
$ jupyter --version
4.4.0

You can open a named .ipynb file by running either:
jupyter notebook my_notebook.ipynb
jupyter-notebook my_notebook.ipynb
The only difference between the two is the hyphen.
I have reported the poor error message in the question in this issue.

If you use the Jupyter notebook, a package named NBInclude.jl can be used.

You are missing the subcommand 'notebook'
jupyter notebook my_notebook.ipynb

Related

How to change Jupyter notebook (windows) shell to bash in Visual Studio code

Related question: How to change Jupyter Notebook (Windows) shell to bash
On windows 10, I created the jupyter configuration file by doing:
jupyter notebook --generate-config
then edited this file to include the path to my git bash executable:
c.NotebookApp.terminado_settings = {
'shell_command': ['C:\Program Files\Git\bin\bash.exe']
}
as referenced in the relevant question above.
On git bash, I then tried to start a jupyter notebook session and I verified that git bash commands worked, e.g. doing:
!ls
worked on the notebook client in my browser.
However, if I open an interactive window or a Jupyter notebook within Visual studio code, I do not get the expected behavior, I instead get the error
'ls' is not recognized as an internal or external command, operable program or batch file.
My question then is:
How do you get jupyter on Visual studio code to use git bash instead of Command prompt on Windows 10?
This worked for me:
go to settings->search for cmd->change it to location of bash-> probably you need to restart VS code
tested with !ls

cannot open .ipynb file even if ipython and jupyter is installed in my pc

I have installed ipython, jupyter etc using pip in my windows 7 pc. Now I want to open a .pynb file from command line. When I typed 'jupyter notebook' it is showing: 'jupyter' is not a recognized internal or external command ...... Can you tell where is the problem? Can't I open the file from command line or I have to install an IDE like 'pycharm' or 'anaconda'?
Please try the below command:
python -m notebook
This should work without anaconda.

Can't launch PySpark in browser (windows 10)

I'm trying to launch PySpark notebook in my browser by typing in pyspark from the console, but I get the following error:
c:\Spark\bin>pyspark
python: can't open file 'notebook': [Errno 2] No such file or directory
What am I doing wrong here?
Please help?
Sounds like the jupyter notebook is either not installed or not in your path.
I prefer to use Anaconda for my python distribution and Jupyter comes standard and will install all necessary path information as well.
After that as long as you have set PYSPARK_PYTHON_DRIVER=jupyter and PYSPARK_PYTHON_DRIVER_OPTS='notebook' correctly you are good to go.
You want to launch the jupyter notebook when you invoke the command pyspark. Therefore you need to add the following to the bash_profile or zshrc_profile.
export PYSPARK_SUBMIT_ARGS="pyspark-shell"
export PYSPARK_DRIVER_PYTHON=ipython
export PYSPARK_DRIVER_PYTHON_OPTS="notebook" pyspark

How to review the codes from .ipynb files in Mac OS ?

I have some code to review and the files have extensions of .ipynb in the end. I install IPython using the command sudo pip install ipython. Now, when I type ipython in the terminal, I get the return -bash: ipyhton: command not found.
What I could do now to review those files? Python is installed in the system. I read the I need to use the command ipython notebook file_name.ipynb to run those files from the terminal.

Can not create a "notebook" using ipython Notebook

I have recently installed ipython using Enthought's EPD python install - and when starting the iPython HTML notebook from the command prompt by typing:
ipython notebook --pylab=inline
I manage to get the localhost browser notebook screen pop up correctly.
However when I try to create a new notebook by clicking "New Notebook" I get the following error message:
"Creating Notebook Failed The error was: Unexpected error while autosaving notebook: C:\Windows\System32\Untitled0.ipynb [Errno 17] No usable temporary file name found"
I am assuming this i sbecause I may not have write privilege for that particular drive. So I have tried to go into the "ipython_notebook_config.py" file and change the following:
# The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = u'C:\Users\Stuart\Documents\iPython'
and
c.FileNotebookManager.notebook_dir = u'C:\Users\Stuart\Documents\iPython'
I have then closed down all the cmd windows and started the ipython notebook agaion. But when I click on "New Notebook" I get the same error message as before:
"Creating Notebook Failed The error was: Unexpected error while autosaving notebook: C:\Windows\System32\Untitled0.ipynb [Errno 17] No usable temporary file name found"
Could someone please help me as to how I can get this working? Any help very much appreciated.
The answer kindly provided by #Jakob in the comments above did the trick:
"Can you try switching to C:\Users\Stuart\Documents\iPython in the terminal before starting the notebook?"
Just change the directory where are run your iPython notebook. For make it, you right-click on the shortcut and edit properties. In this properties, a field named "run directory" or something like that. Put your link in this field.
I just experienced the same problem. I even erased all the untitled.ipynb files in the directory. Then I realized that I had other copies of Anaconda terminal open. When I closed them and tried again, things went back to normal.
If you run the IPython as administrator you won't run into error for starting a new notebook. To do that right click on the Ipython shortcut and click on run as administrator.
I also had the same problem, I was not able to create the new notebook or access existing notebook present in that directory.
Error Message - Unexpected error while saving file:/path/ database is locked
Turns out my old anaconda jupyter notebook terminals were open and running in the background. Every time I started jupyter notebook I used the new instance that led me to this problem. When I closed all terminals and restarted new Jupyter notebook terminal it started working again.
Many of the problems with Anaconda/Jupyter/Notebooks can be solved by examining and cleaning up what you have in your environmental variables such as Path or, if you trying to set up files to store Notebooks that you develop.
There is a very good discussion of environmental variables here:
http://johnatten.com/2014/12/07/adding-and-editing-path-environment-variables-in-windows/
It is obvious that if Anaconda/Jupyter/Notebook can't find the files they can't run them.
At a minimum your path in environmental variables should contain:
c:\users\*******\Anaconda3 where ******** is your user name
c:\users\*******\Anaconda3\Scripts
then you could create environmental variables that point to your personal Notebook code directories: (note: there can't be any spaces in the addresses) in Windows Environmental Variables (System Properties --> Environmental Variables --> add to User and System variables
variable value
NOTEBOOK address of your personal Notebook location
TESTING address of your Notebook Testing location
With this setup you can on the Anaconda Command
jupyter notebook %TESTING%
or
jupyter notebook %NOTEBOOK%
Another way you can go to your own Notebook directory is to change
jupyter_notebook_config.py
Go to:
## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = 'your Notebook directory address goes here'
remove the ## and enter your directory using \'s instead of \ in the address
Then anytime you enter 'jupyter notebook' you will start at your Notebook Directory.