Reputation: 8052
I tried following the instructions given on the Jupyter Notebook documentation.
Unfortunately, I haven't been able to figure it out. Where exactly is this "start in" field?
I've a windows 7 (64 bit) system, with Anaconda3 installed (not in C drive). I want to change Jupyter start folder location.
Upvotes: 548
Views: 1082027
Reputation: 913
The best and easiest way is stated in the Jupyter Docs Beginner Guide.
It has solution for Windows and Mac, solution for Mac is also applicable for Ubuntu or any Linux distro.
For Windows (from the guide):
- Copy the Jupyter Notebook launcher from the menu to the desktop.
- Right click on the new launcher and change the Target field, change
%USERPROFILE%
to the full path of the folder which will contain all the notebooks.- Double-click on the Jupyter Notebook desktop launcher (icon shows [IPy]) to start the Jupyter Notebook App. The notebook interface will appear in a new browser window or tab. A secondary terminal window (used only for error logging and for shut down) will be also opened.
Upvotes: 1
Reputation: 362
There is also another good way to execute jupyter in a custom folder, just create a text file in windows and add the following:
cd path\to\root\of\C\drive
D:\path\to\your\folder (D is your custom drive)
jupyter notebook
and then save this file as .bat.
execute!
Upvotes: 0
Reputation: 391
Above answers is not work and too complicated for someone who use Anaconda and Window:
Go to C:\Users\username.jupyter\
create a file: jupyter_server_config.json (For lab) or jupyter_notebook_config.json (For notebook)
json content:
For lab:
{
"ServerApp":{
"root_dir": "your workspace directory"
}
}
For notebook:
{
"NotebookApp": {
"notebook_dir": "your workspace directory"
}
}
Save file and relaunch lab or notebook
P.S the.json config keywords is the same as .py, so you add other config e.g : change your password
Upvotes: 1
Reputation: 73
I have seen all and no one tries to mention the distintion for jupyter-lab and jupyter notebook specially in windows 11 for novice like me this is what i have done
Upvotes: 1
Reputation: 65
I have just ported my projects to wsl, runninbg ubuntu 20+. I too need to use a file-location within Win, In addition to the notebook_dir (well documented above) there is also the issue of browser redirection which should be changed from the default behaviour. This answer DOES NOT relate to the notebook server.
The generation of the configuration file is dealt with in the previous reponses; therefore I will not describe that here. Please set the following in the
This enables the notebook to seamlessly start on your preferred Win directory.
Upvotes: 0
Reputation: 761
I noticed that Jupyter will always launch the folder that is native to the command prompt (I am sure the same applies to terminal). Simply cd to your desired folder and then launch Jupyter.
Upvotes: 2
Reputation: 161
In case someone still looking for an answer/ other options. Here what works for me best.
Create a .bat file.
Inside the .bat file. Change C:\Users\usr\folders\ to folder you want jupyter notebook to open in default.
cd C:\Users\usr\folders
jupyter notebook
Save the .bat file and place it where ever you want. Usually I would create .bat file for each project I am working on. Think of these .bat files as shortcuts.
Double click .bat file to launch jupyter notebook on the intended path.
Upvotes: 1
Reputation: 1859
As of today December 2021, Jupyter lab had made a few changes in its config file. So if you are following the Marneylc's answer which is also the accepted answer then you should look for this line
# c.ServerApp.root_dir = ''
Instead of
#c.NotebookApp.notebook_dir = ''
Add your desired location inside the quotation and it will work fine 🙂
Upvotes: 0
Reputation: 7466
For old Jupyter Notebook interface installed with notebook
package and run as jupyter notebook
(see the next section for the identical interface installed with nbclassic
and run with jupyter nbclassic
, and for JupyterLab):
Open cmd
(or Anaconda Prompt) and run jupyter notebook --generate-config
.
This writes a file to C:\Users\username\.jupyter\jupyter_notebook_config.py
.
Browse to the file location and open it in an Editor
Search for the following line in the file:
#c.NotebookApp.notebook_dir = ''
Replace by c.NotebookApp.notebook_dir = '/the/path/to/home/folder/'
Make sure you use forward slashes in your path and use /home/user/ instead of ~/ for your home directory, backslashes could be used if placed in double quotes even if folder name contains spaces as such :
"D:\yourUserName\Any Folder\More Folders\"
Remove the #
at the beginning of the line to allow the line to execute
For recent nbclassic
and JupyterLab >= 3 use c.ServerApp.root_dir
instead of c.NotebookApp.notebook_dir
(and jupyter server --generate-config
instead of jupyter notebook --generate-config
).
For context see migration guide and this question on differences between server
and notebook
.
Upvotes: 722
Reputation: 5357
For Windows users, here is a snippet to let you right click folders and open Jupyter Lab there.
def add_jupyter_to_context_menu(self):
import winreg
key = winreg.HKEY_CURRENT_USER
command_value = rf'cmd.exe /k jupyter lab --notebook-dir="%V"'
handle = winreg.CreateKeyEx(key, "Software\Classes\directory\Background\shell\Open with JupyterLab\command", 0,
winreg.KEY_SET_VALUE)
winreg.SetValueEx(handle, "", 0, winreg.REG_SZ, command_value)
# You need to download the icon yourself, or leave this part out for no icon
icon_value = fr"C:\some_folder\jupyter_icon.ico"
handle = winreg.CreateKeyEx(key, "Software\Classes\directory\Background\shell\Open with JupyterLab", 0,
winreg.KEY_SET_VALUE)
winreg.SetValueEx(handle, "icon", 0, winreg.REG_SZ, icon_value)
def remove_jupyter_from_context_menu(self):
import winreg
key = winreg.HKEY_CURRENT_USER
winreg.DeleteKey(key, "Software\Classes\directory\Background\shell\Open with JupyterLab\command")
winreg.DeleteKey(key, "Software\Classes\directory\Background\shell\Open with JupyterLab")
Upvotes: 4
Reputation: 21
If you are working with jupyter lab and want to modify the configure file, the parameter need to be updated is :
c.ServerApp.root_dir = /path/to/directory/you/want
Upvotes: 1
Reputation: 7484
As of 2020, for Windows...
The configuration is for an installation from miniconda, but it'll be the same for anaconda. The shortcut can be modified by looking at its properties. The target of the link has this format:
C:\Users\A_User\miniconda3\python.exe C:\Users\A_User\miniconda3\cwp.py C:\Users\A_User\miniconda3 C:\Users\A_User\miniconda3\python.exe C:\Users\A_User\miniconda3\Scripts\jupyter-notebook-script.py "%USERPROFILE%\Documents\Jupyter"
There are three parts:
1: The first part launches a wrapper
C:\Users\A_User\miniconda3\python.exe C:\Users\A_User\miniconda3\cwp.py
This wrapper ensures the third part (which is the actual shortcut) can be executed with the proper configuration, depending on the environment chosen for execution. Code is here.
2: The path to the Script folder
Scripts are in a subfolder Scripts
of the folder used for each environment. Give the path to the environment you want, the wrapper will do the rest. In my case I'm using the base
environment:
C:\Users\A_User\miniconda3
This fragment is passed to the script which identifies it as variable prefix
, the full path computed from the variable and then added at the beginning of environment variable PATH
and also replaces the current content of CONDA_PREFIX
.
3: The command to run
This is the command to be processed by the previous wrapper:
C:\Users\A_User\miniconda3\python.exe C:\Users\A_User\miniconda3\Scripts\jupyter-notebook-script.py "%USERPROFILE%\Documents\Jupyter"
It runs Python with the jupyter-notebook-script.py
script to launch Jupyter notebook, and it adds the specific initial folder "%USERPROFILE%\Documents\Jupyter"
which corresponds to the location I use to store notebook files. This path is the one you asked for.
The paths can be adjusted to your specific configuration and preferences for environment to use and storage.
Upvotes: 0
Reputation: 395
This is the solution I found for Windows 10 Anaconda Navigator.
step 1: Search for Jupyter Notebook and navigate to the file location. It is something like below
Step 2: Right click on Jupyter Notebook and go to Properties. Add your directory to Target. Mine was "D:\Education\Machine Learning"
Step 3: Do not launch Jupyter Notebook from Anaconda Navigator. Use the above shortcut instead.
Upvotes: 4
Reputation: 483
The easiest and the simple way to open Jupyter Notebook from the desired location is to open Anaconda Prompt(possible only if you installed Python using Anaconda Distribution).
Open the desired location in Windows File Explorer, copy the desired location from the address bar of Windows File Explorer. Alt + D goes to the address bar and Ctrl + C copies the location.
Now open the Anaconda Prompt and type the following command:
cd D:\desired location
Somehow, the Anaconda Prompt returns to the original location. Enter 'd:' and the prompt will reach your desired location(as shown in the image below). Note that you must enter the drive letter of your desired location(C: for C:\ drive-the primary partition).
Afterward, type 'jupyter notebook' and the Jupyter Notebook will be opened.
Note that the Jupyter Notebook's home page does not list anything as the folder is empty.
Once a Python3 notebook is created, the home page will list the files.
This way you can open Jupyter Notebook from any location, without having to deal with all the complexities of going to the installed location and making the necessary tweaks.
Upvotes: 12
Reputation: 51
Easy way!
1 - Type jupyer notebook
in start menu
2 - Make shortcut on desktop
of jupyter notebook
( Right click mouse!)
3 - Only drag and drop
your favorite folder
in the shortcut
Upvotes: 0
Reputation: 606
Open Anaconda Prompt and write to open a notebook folder in G drive jupyter notebook --notebook-dir 'G:'
there is no "="
Upvotes: 5
Reputation: 3821
First try to run
jupyter notebook --notebook-dir="C:/Your/Desired/Start/Directory/"
in a command line (cmd) to see if the Jupyter notebook opens at the desired location.
If yes, then you can make it a shortcut by:
In a Windows File Explorer or on the desktop, Right click > New > Shortcut
Enter the following location and click next:
jupyter notebook --notebook-dir="C:/Your/Desired/Start/Directory/"
Now you have a shortcut to start Jupyter at the location you want. This works on Windows 7, macOS, and Linux.
For windows best to enclose the path in double quotes "
as single quotes '
will not work if there is a space in the pathname
Note if you found the error saying the path is not valid, try using common slash /
instead of backslash \
in the path like
jupyter notebook --notebook-dir="D:/"
Upvotes: 159
Reputation: 6930
For Windows 10:
Properties
./
not \
for path) as showed on the screenshot:Upvotes: 24
Reputation: 1465
jupyter notebook --notebook-dir=%WORKING_DIR%,
where %WORKING_DIR% (H:\data\ML) - directory where you're going to work
It is the simplest one-line command way, IMHO
Upvotes: 1
Reputation: 9343
I am on Windows 10 but same version of Anaconda.
Upvotes: 201
Reputation: 160
If your goal is to permanently change the start-up location. You can do so by changing the shortcut for the notebook. Assuming you are on Windows 10
Good Luck
Upvotes: 5
Reputation: 1041
So the answers above helped, but please allow me to make it clear so other people who aren't very familiar with MS-Windows can work it out in the same way:
This issue happens when Windows 10 installs Anaconda with Python, Ipython, and Jupyter Notebook.
First open the Anaconda Prompt and type the following into the prompt:
jupyter notebook --generate-config
You will get something like this:
You don't have to do anything on the prompt anymore. I didn't snapshot my full address because of privacy, but it shows something like:
C:\Users\name\.jupyter
Find this folder on your C: drive, and in this folder, find the python file jupyter_notebook_config.py
. Drag the file into a Notepad ++ to edit it.
When editing, look around line 214, for the string that looks like:
#c.NotebookApp.notebook_dir = ''
Uncomment it, i.e., delete the "#" in the first column. Now add our target folder address into the ' ' like this:
c.NotebookApp.notebook_dir = 'C:\\Users\\name\\Desktop\\foldername'
Then save the file. Then open anaconda prompt again, type jupyter notebook
. This should launch Jupyter Notebook in the browser in the folder with the above address. Here, the key point is to UNCOMMENT (which means to delete) the # at front of the line, and then, USE \\ double slashes (for the path separator) between folders. If you use only single slashes \, it won't work.
That's all.
Upvotes: 42
Reputation: 171
This is what I do for Jupyter/Anaconda on Windows. This method also passes jupyter a python configuration script. I use this to add a path to my project parent folder:
1 Create jnote.bat somewhere:
@echo off
call activate %1
call jupyter notebook "%CD%" %2 %3
pause
In the same folder create a windows shortcut jupyter-notebook
TARGET: D:\util\jnote.bat py3-jupyter --config=jupyter_notebook_config.py
START IN: %CD%
Add the jupyter icon to the shortcut.
2 In your jupyter projects folders(s) do the following:
Create jupyter_notebook_config.py, put what you like in here:
import os
import sys
import inspect
# Add parent folder to sys path
currentdir = os.path.dirname(os.path.abspath(
inspect.getfile(inspect.currentframe())))
parentdir = os.path.dirname(currentdir)
os.environ['PYTHONPATH'] = parentdir
Then paste the jupyter-notebook
shortcut. Double-click the
shortcut and your jupyter should light up and the packages in
the parent folder will be available.
Upvotes: 0
Reputation: 849
In case you are using WinPython and not anaconda then you need to navigate to the directory where you installed the WinPython for e.g. C:\WPy-3670\settings\.jupyter\jupyter_notebook_config.py
You need to edit this file and find the line
#c.NotebookApp.notebook_dir = ''
change it to for e.g.
c.NotebookApp.notebook_dir = 'D:/your_own_folder/containing/jupyter_notes'
You also need to change backslash \
to forward slashes /
. also make sure to uncomment the line by removing #
Upvotes: 0
Reputation: 49
You can use a program called FileMenuTools from Lopesoft for your command prompt and just type 'jupyter notebook'.
Alternatively, you can also use it to create a dedicated shortcut using program C:/windows/System32/cmd.exe and arguments /k jupyter notebook --notebook-dir="%FOLDERPATH%" but this opens the notebook in the parent folder so you have to click down.
Upvotes: 0
Reputation: 91
This method may not be relevant to your problem but to me it is quite useful.
Just type "cmd" in the address bar to open the Command Prompt, and then "jupyter notebook".
Via this method, you can quickly open Anaconda jupyter from any path you currently staying on Windows system.
Upvotes: 6
Reputation: 3436
Open in Terminal
jupyter notebook
to run the Notebook from the desired location.
Upvotes: 1
Reputation: 71
Below is how the same issue I faced got resolved. Most of the steps I took to solve the issues are already described in the solutions provided earlier by others.
There are two ways to start Jupyter Notebook application
There are different ways to configure Jupyter Notebook application to save the notebooks in a folder other than the default.
If using Anaconda Navigator to launch notebook
In case of using the Anaconda navigator to launch Jupyter notebook application, the way to configure is to un-comment the "c.NotebookApp.notebook_dir" field in "jupyter_notebook_config.py" and add the path. After updating the field looks like: c.NotebookApp.notebook_dir = <Enter the absolute path here>
In case of Windows and when Anaconda is installed for a particular user, this file is located in C:\Users\<USERNAME>.jupyter.
If you don;t find ".jupyter" folder then do the below steps to create it
If using the shortcut (name: Jupyter Notebook) to Jupyter Notebook application to launch it
If you examine the command in the target box of this shortcut, you will notice that Notebook app is started by executing the file "C:\Users\<USERNAME>\Anaconda3\Scripts\ jupyter-notebook-script.py" which accepts a path parameter.
The basic approach to define the location where the notebook files will be saved is --> to provide the path of the required folder when starting the Jupyter Notebook application. This can be done in two ways:
Follow the below steps: (Note: Replace the text in angle brackets with the actual text)
Replace "%USERPROFILE%" with
a. Either: the environment variable created to point to the folder where you want to store the notebook files. The command will look like: C:\Users\<USERNAME>\Anaconda3\Scripts\jupyter-notebook-script.py %<ENVIRONMENTVARIABLE>%
b. OR: the absolute path to the work folder you want the notebook files to be stored in. The command will look like: C:\Users\<USERNAME>\Anaconda3\Scripts\jupyter-notebook-script.py <F://folder//subfolder>
Replace the text (path) in "Start In" box with:
a. Either: the environment variable created to point to the folder where you want to store the notebook files. The text in "Start In" box will look like: %<ENVIRONMENTVARIABLE>%
b. OR: the absolute path to the work folder you want the notebook files to be stored in. The text in "Start In" box will look like: <F://folder//subfolder>
Note 1: If there are spaces in the path then the whole path should be enclosed in double quotes.
Note 2: The paths in this solution apply to the situation when Anaconda 3 (and Jupyter 3) is installed on Windows for a particular user (not for all users).
I personally preferred to define environment variable rather than hard coding the path in the shortcut.
Upvotes: 3
Reputation: 11
After many tries I have done it. I have mentioned the easiest steps below:
Right click on the jupyter launcher icon from start menu or desktop or anaconda navigator
Now you need to change 2 things on the screen: Add your path to both target and start in the properties window
Caveats:
a. Your path needs to be in the same drive as the drive in which jupyter is installed. Since mine was in C drive, I used the following path "C:/JupyterWorkLibrary"
b. For target, at the end of the existing path, i.e, after sript.py", add this after a space. Some people have mentioned removing %USERPROFILE% from target. I did not come across this. Image for jupyter properties
c. For start in, add the same path. I have used a path without spaces to avoid issues. I would also suggest stick to using path in double quotes anyways d.I have also used forward slashes in the path
Now just launch the notebook. It should open into the right folder.
Hope this helps.
PS: I am sure there are other ways, this worked for me. I am not even sure of the constraints mentioned. It's just that with these steps I could get my job done.
Upvotes: 1