Every day, I repeat the same procedure over and over to open a Jupyter notebook.
I navigate with File Explorer to my work folder C:\Users\MYSELF\WORKFOLDER
Open command prompt there
Enter the command jupyter notebook or jupyter lab
If you don't have jupyter in your python base environment it becomes even more painful because you need to activate some virtual environment.
Is there a quicker way?
I'd love to have an icon on my desktop that I can just click on!
Right-click on your desktop New -> Shortcut. Then enter the following for the location:
C:\Windows\System32\cmd.exe /k cd C:\Users\MYSELF\WORKFOLDER && jupyter notebook
This will start a command prompt and execute the two commands cd C:\Users\MYSELF\WORKFOLDER and jupyter notebook.
Click Next and you can then give that shortcut a name and create it with a click on Finish.
Related
I run Windows10, use the latest Anaconda3 (2019) and have installed Jupyter Notebook through conda.
I used to run Jupyter Notebook by navigating to a folder where I save my Jupyter Notebooks named \jupyter_notebook_files and from that directory running the command jupyter notebook from cmd.
A few hours ago I deleted for space saving reasons a folder named ABC.
When now I try to run Jupyter Notebook I get the message:
[C 20:57:04.610 NotebookApp] Bad config encountered during initialization:
[C 20:57:04.611 NotebookApp] No such notebook dir: ''D:/ABC''
I dealed with this problem by typing:
C:\WINDOWS\system32>jupyter notebook --notebook-dir='D:\DIGITAL_LIBRARY\Jupyter_Notebook_Files'
Is there a way to make this folder default and not have to repeat each time the clause: -notebook-dir='D:\DIGITAL_LIBRARY\Jupyter_Notebook_Files' ?
Try to run this code on the terminal:
jupyter --config-dir
The output will be a path. Go to that folder and delete all the contents.
Then run
jupyter notebook
Close Anaconda and or any related programs that are running (Presumably Jupyter is not). Drop down to the command prompt in Windows 10 (or other terminal if you have a different OS). Enter the command:
jupyter --config-dir
This will give you the configuration directory for Jupyter, which will most likely look something like this:
C:\Users<Your Local Account>.jupyter
use CD to go to that directory and use Notepad or your favorite text editor to edit the file called "jupyter_notebook_config.py" - for example:
notepad jupyter_notebook_config.py
Now use find (F3) to search for the line that begins with "c.NotebookApp.notebook_dir = ". The directory that follows the "=" sign probably doesn't exist. So copy that and create the directory OR enter the directory you want instead.
Save and Start Jupyter.
I want to change the default directory that Jupyter Notebook opens on. My OS is windows 10. I changed the c.NotebookApp.notebook_dir setting in the jupyter_notebook_config.py file. This works when I open Jupyter Notebooks thru Anaconda navigator, i.e. if I open Anaconda Navigator first and then launch Jupyter Notebooks from there.
MY problem is that when I launch jupyter notebook by typing it in the windows start/search menu, it does not open in the directory specified in the c.NotebookApp.notebook_dir setting in the jupyter_notebook_config.py file.
Any help on this will be appreciated. Thanks in advance!
When you typing it in windows search box, you run the shortcut actually, even you had edit c.NotebookApp.notebook_dir setting, just right click the the shortcut and open the files location or edit the shortcut directly
ex: C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)\Jupyter Notebook.lnk,
right click the properties of shortcut, you will see the target is
C:\Users\user\Anaconda3\Scripts\jupyter-notebook-script.py "C:\Users\user",
delete the default value to
C:\Users\user\Anaconda3\Scripts\jupyter-notebook-script.py
and run it, it will get the c.NotebookApp.notebook_dir setting
When I write jupyter notebook in terminal it doesn't open notebook, it opens Jupyter tree. What can be the problem?
The command you give should open Jupyter in the filesystem view first. You then navigate from there to a notebook and double-click that, which will open the notebook in a new browser tab.
Question: When I write jupyter notebook in terminal it doesn't open notebook, it opens Jupyter tree. What can be the problem?
Answer: You missed the path for the notebook (say, notebook_to_open.ipynb).
Try again with command like this:
(windows)
jupyter notebook c:/path/to/your/notebook_to_open.ipynb
(linux)
jupyter notebook ~/path/to/your/notebook_to_open.ipynb
I'm new to coding but I simply want to change directory and run jupyter. The problem is cmd instantly closes once it reaches the jupyter notebook command. Tried cmd /k too but it doesn't have an effect. I must being doing this wrong.
F:
cd directoryname
activate environmentname
jupyter notebook
pause
Solution:
The commands were closing the prompt for some reason when executed in a .bat (they don't when typed). The fix was to type call before the commands.
F:
cd directoryname
call activate environmentname
call jupyter notebook
pause
The commands were closing the prompt for some reason when executed in a .bat (they don't when typed). The fix was to type call before the commands.
F:
cd directoryname
call activate environmentname
call jupyter notebook
pause
Create a simple batch file (jnote.bat):
#echo off
call jupyter notebook "%CD%"
pause
In the same folder create a shortcut to the batch file and rename it to jupyter-notebook.
Open the shortcut properties and change the icon to the jupyter.ico. You will find this in the .\Menu sub-folder in your Anaconda distribution. You should now have a shortcut with the) nice jupyter icon.
Copy the shortcut to all the folders that you use for your notebooks.
Double-click the shortcut to open jupyter-notebook that folder.
For Jupyter, use:
%USERPROFILE%\Anaconda3\python.exe %USERPROFILE%\Anaconda3\cwp.py %USERPROFILE%\Anaconda3 %USERPROFILE%\Anaconda3\python.exe %USERPROFILE%\Anaconda3\Scripts\jupyter-notebook-script.py "**file location**"
for Jupyter lab:
%USERPROFILE%\Anaconda3\python.exe %USERPROFILE%\Anaconda3\cwp.py %USERPROFILE%\Anaconda3 %USERPROFILE%\Anaconda3\python.exe %USERPROFILE%\Anaconda3\Scripts\jupyter-lab-script.py %USERPROFILE%
Save it in a .bat file, with necessary changes at 'UserName' and 'File Location' . Keep it as a single line. Just double click the file to open jupyter notebook at the location.
Note: File Location is the location of the notebook to open.
Alternatively, you can use the same commands to create windows shortcut, without the need for the .bat file:
On the desktop, right-click -> new -> shortcut.
As the location of the item, paste the code above.
Then, you can double click the shortcut to launch jupyter. Unlike the bat file, you can also pin this shortcut to taskbar.
For details on how to setup jupyter lab, check out Running JupyterLab as a Desktop Application in Windows 10
Assuming activate and jupyter are executables or otherwise valid commands, everything should be okay. Since you're saying the cd command is probably the culprit, try the below:
Perhaps you are trying to change to a directory on a different drive... if this is the case you will need to use cd /d directoryname instead.
If this doesn't work, try putting a bunch of pause statements between each command to see exactly where it is breaking.
You can used just that simple code:
d: & activate your_env & jupyter notebook
It's really working for me
I found an alternative way to solve this problem without a .bat.
Search your start menu for "Jupyter Notebook". You should find a shortcut called:
"Jupyter Notebook (environmentname)"
This short cut was created when I set up my environment. In my case environmentname is py35.
To change the directory that Jupyter Notebook starts in find the "Anaconda Prompt" shortcut. Then open "Properties>Shortcut" and change the "Starts in:" field to your desired directory.
If you did not add conda to your path, the following script might be helpful for you. According to https://docs.anaconda.com/anaconda/install/multi-user/ you might even want to check C:\ProgramData\Anaconda but I didn't want to add something to the Batch script that I haven't checked myself.
:: Starts JupyterLab
SET CONDA_ENV=my-specific-conda-environment-name
where conda 2> nul
IF ERRORLEVEL 1 (
ECHO "Conda is not available in your PATH. Guessing the location of the installation..."
CALL C:\Users\%USERNAME%\Anaconda3\Scripts\activate %CONDA_ENV% || (
ECHO "Either Conda or the environment was not found."
PAUSE
)
) ELSE (
CALL activate %CONDA_ENV%
)
CALL jupyter lab || (
ECHO "JupyterLab encountered an error, please check the error message"
PAUSE
)
here is the batch file for this problem
cd directoryname
call activate envName
start jupyter notebook
This is what I use to activate my virtual environment, then run my notebook.
#echo off
call env\Scripts\activate
call jupyter-lab
Saved this as a .bat, so all I have to do to open the notebook is run it.
The best solution I found so far, which works without creating a custom batch file:
Navigate to activate.bat in C:\Users\<youruser>\<Anaconda3 or miniconda3>\Scripts\activate.bat
Right click and create a link to the activate.bat from the Desktop
Right click to change property of the link in the tab link
In Target you enter: %UserProfile%\<Anaconda or miniconda3>\Scripts\activate.bat <your-env-name> && #CALL jupyter lab (when you do not know your environment name you can check them in the file environments.txt in C:\Users\<youruser>\.conda
In the field below you enter your path to the project folder (not to the environment), this is where the script will start.
After this you can edit the icon / title / .. of the link and execute.
This is my code. It starts jupyter notebook in the directory it is saved:
#echo on
cd 'your_path_to_anaconda' /condabin
call activate.bat
cd %~dp0
call jupyter notebook
cmd \k
Related posts: Open an ipython notebook via double-click on osx
How can I open Ipython notebook from double click? I always cd to the directory of the notebook, then type ipython notebook in the browser and then open it in the browser. This steps is very inconvenient.
In windows, I remembered that I can change the directory in the browser, but in linux there is no way to explore to other directory via browser, if I want to open a new book in another directory, I have to restart another kernel as above, which annoys me.
Is there any simple and verified way to do this?
You can use a project like nbopen that handle that and will open the browser on the right notebook + start an IPython server if one is not yet running.
pip install nbopen.
open Automator, create new Application
Drag'n drop Run Shell Script
Change Pass input to as arguments
Copy/paste this script:
variable="'$1'"
the_script='tell application "terminal" to do script "nbopen '
osascript -e "${the_script}${variable}\""
Save the new application to Applications directory as nb_open
Right click any ipynb file and select "Open with > Other" and select the nb_open in the Applications folder. Don't forget to check "Always Open With".
Select an ipynb file, get info (command + i) > Open With (select nb_open if not selected already) > Click Change All.... Done.
To "promote" Yogesh's helpful comment to a fully self-contained answer:
Windows 10
In a CMD or PowerShell window with administrative rights (e.g. launched quickly with Win+X, then A), run:
pip install nbopen
python -m nbopen.install_win
Profit!
Double-click on *.ipynb files now starts a new server or reuses an existing instance.
One way to open a Jupyter notebook directly by double-clicking on the file is to associate the .ipynb file extension with the jupyter-notebook command. Here's how to do it on a Windows system:
Right-click on the Jupyter notebook file that you want to open.
Select "Open with" and then choose "Choose another app".
Select "More apps" and then scroll down to the bottom and choose "Look for another app on this PC".
Navigate to the directory where the jupyter-notebook.exe file is located (usually in the Scripts subdirectory of your Python installation), and select it.
Check the box next to "Always use this app to open .ipynb files" and then click on "OK".
Now, when you double-click on an IPython notebook file, it should open directly in the Jupyter notebook.
On a Mac or Linux system, you can set the default application for .ipynb files by using the xdg-mime command. First, determine the full path to the jupyter-notebook executable:
which jupyter-notebook
This will return the path to the executable. Then, use the xdg-mime command to set the default application for .ipynb files:
xdg-mime default jupyter-notebook.desktop application/x-ipynb+json
Replace jupyter-notebook.desktop with the path to the jupyter-notebook executable that you determined earlier. Now, when you double-click on an IPython notebook file, it should open directly in the Jupyter notebook.