How to change the Jupyter start-up folder
Asked Answered
H

39

534

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.

Heterochromosome answered 7/2, 2016 at 14:43 Comment(3)
Under Anaconda, or in general? GUI, command-line or both?Disagreeable
Related specific case: How do I start jupyter notebook from command-line to run in my current directory, without editing config files or passing hard paths?Disagreeable
My preferred way of doing it is to create a .bat with command cmd /c "cd C:\My\Desired\Folder & jupyter notebook" and store it somewhere. Create a shortcut JupyterNB.bat - Shortcut to this bat file. Then copy this shortcut to start menu folder like %AppData%\Microsoft\Windows\Start Menu\Programs\Jupyter\JupyterNB.bat - Shortcut for a quick launch in windows menu.Hilliard
G
710

Jupyter Notebook and JupyterLab < 3.0

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):

  1. Open cmd (or Anaconda Prompt) and run jupyter notebook --generate-config.

  2. This writes a file to C:\Users\username\.jupyter\jupyter_notebook_config.py.

  3. Browse to the file location and open it in an Editor

  4. Search for the following line in the file: #c.NotebookApp.notebook_dir = ''

  5. 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\"

  6. Remove the # at the beginning of the line to allow the line to execute

JupyterLab >= 3, Jupyter Notebook Classic, and RetroLab

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.

Gibeonite answered 9/11, 2016 at 19:51 Comment(26)
Make sure you uncomment this line. That got me for a bit.Alonsoalonzo
Very important about forward slashes. So you would write: C:/Users/username/ . This got me because we don't normally write paths like this on WindowsLarcenous
Sorry, but this does not work for me, got exactly this line (uncommented, of course): c.NotebookApp.notebook_dir = 'E:/Daniel/Python Projects/' -- It keeps opening somewhere else.Calceolaria
@Daniel thats probably due to single quotes and a space in the project path. use double quotes or change path to something without space.Mohammedmohammedan
I could't make it work until I copied the ".lnk" file to the desired directory. Now when I start Jupyter from there, it opens that directory. I also made the required changes in the config file of course.Elizabethelizabethan
This solution wasn't complete for me, so I had to add in the C:\Users\username\.jupyter\jupyter_notebook_config file this line: c.FileNotebookManager.notebook_dir ='your path'. Also, in the properties change the Start in path to: C:\Users\ your_user \AppData\Local\Continuum\Anaconda3\ScriptsWurth
The correct answer to OP's question is a combination of this answer, comments of two users under: csaladenes and Shantnu Tiwari, and also answer below by cb4 and also two comments in there by Stefano and Oskar Świerad. I'm on Win10, Anaconda 3Insightful
No longer works on Windows, now you have to change %USERPROFILE% in the shortcut target. Here are the official instructions.Abbotson
Windows10: I edited C:\Users[username]\.jupyter\jupyter_notebook_config.py, using double quotes and the Windows backslashes, to change to a directory on a different drive. This works when accessing Jupyter through the box in Anaconda Navigator. However, it does not work when using the Jupyter Notebook icon in the Start Menu (listed under Anaconda3). Apparently that start menu entry does not read the configuration file.Bregma
I'm using Windows 7. I did the above and changed to a custom path on my c-drive. I also used forward slash, which made it work, it didn't work with back slash. Also, I removed the %USERPROFILE% when starting up jupyter notebook.Broadloom
For me it works as of today in Windows 10 with usual forward slash "/" and no more changes. The accepted solution is faster, but this one is in my opinion cleaner and better; upvoted accordingly. Thanks.Transect
The official instructions didn't work for me but this did. Win7 by the way. I feel this should be the accepted answer, since the other is just temporary.Williford
Show the location of the config directory: jupyter --config-dir (from docs)Nightcap
This process works on Windows 10 as of Nov 2019. When you run the generate-config the location of the file is displayed. Went there, found the setting and pasted the python labs folder I had set up and enclosed it in double-quotes. Made sure it was uncommented. Saved the file. Ran Anaconda as admin. Worked fine. It is the answer for me.Kidron
This solution had been working for me (on Windows 10) until today. Then it quit. I used cb4's solution below and I'm back to opening in the folder I want.Ensnare
This still works with Windows 10 version (of March 2020) and Jupyter 6.0+. Must restart anaconda / jupyter server after changing the path ThanksMonologue
I struggled with this problem for a long time. Thanks for this answer, it simplified the processTrivium
Make sure that the line in the config file is not indented, otherwise it generates an error message and is ignored.Hygrostat
This solution worked for me for JupyterLab 3.0.14 on Windows 10 as of Nov 2021, even when I tried the option for JupyterLab < 3.0.Skewback
This solution did not work for me on Windows 10. Autumns response is correct and should be at least another, if not the answer to this question. It is the simplest and most official one.Aristate
The described method worked for me in one go today copying the path directly and putting an r before the path.Lux
For me, that's what worked: Start Menu > Anaconda3 (64-bit) > Right-click on Jupyter Nobebook (Anaconda3) > More > Open File Place... That opened the C:\Users\myuser\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit) folder for me. Right-click in Jupyter shortcut icon and click Properties. In destiny, change USERPROFILE by any variable you want. Then in Settings search for "environment variables". In your account variables table, Click "New" and create a new variable called the name you had put, and the full path to the desired folder into the Value field.Citronella
In Windows you have to add 'r' before path in step 5 like c.NotebookApp.notebook_dir = r'D:\Any Folder\More Folders\'Intyre
@Skewback The solution for JupyterLab < 3.0 still works for me even now with Jupyter Notebook 6.4.12. The other solution was more complicated.Consubstantiation
Also change 'c.ServerApp.preferred_dir'Titanium
WARNING: This accepted answer no longer works in latest version and it may cost developers valuable time. This answer should be updated.Fight
K
242

cd into the directory or a parent directory (with the intended directory you will work nested in it).

Note it must be a folder (E:\> --- This will not work)

Then just run the command jupyter notebook

Kalil answered 12/9, 2016 at 15:28 Comment(14)
This is great for exception cases; I don't want to change c.NotebookApp.notebook_dir property of jupyter_notebook_config, nor do I want to change Start in property of the Jupyter (windows shortcut), I just want to launch Jupyter once or twice in a specific directory; just cd there (or see @DRozen's answer)Brookes
This is most appropriate, working directory can be changed as and when required!!Complacent
Worth mentioning that this always works when done in Anaconda prompt - not everyone has access to conda commands via cmd.Dunois
IMPORTANT: After the typical nbconfig setup, also remove %USERPROFILE% from your Jupyter Notebook shortcut Target field.Alonsoalonzo
This is most concise way. However, on windows this needs to be run from Anaconda prompt, as path variables are not updated by Anaconda (recommended settings).Tamtam
As a side note for those who discover Jupyter (it took me some moments to realize that): the command jupyter notebook is exactly the command to run - which will open a web interface to choose the actual notebook to use. The notebook in jupyter notebook is part of the command to be typed as it, not the name of your notebook.Viscus
If anyone is having a unicode problem: #1348291Continuate
Also important, if you have the shortcut pinned to the start up menu and you made a backup before you edited, you will have to unpin it and pin your new shortcut because Windows will track the changes and keep displaying your old shortcut.Penicillin
is jupyter notebook one command(notebook as parameter) or two commands?Imbibe
@TheRedPea - changing the config option for c.NotebookApp.notebook_dir doesn't seem to actually change the working directory. It displays the tree in the Jupyter interface as rooted to what dir I set, but the actually notebook still seems to use the same root. For instance, all my import statements still use the old root, even after setting c.NotebookApp.notebook_dirPhenomenal
Hi @JamieMarshall thanks for pointing out that c.NotebookApp.notebook_dir may not work, can you check the other answer with more details on that; (i.e. make sure to uncomment, make sure to wrap in quotes, use forward slashes), if you report that it works then you'll help someone, if you report that it still doesn't work, then I think you'll help people avoid using that approach. Thanks!Brookes
@TheRedPea - I've since solved this, and indeed it is just as my comment says. The reason for this is that the IPython kernel still looks in the Python root, no matter what you set the notebook dir too. Thus if you really want to use python in a different dir (what I would call a 'working directory') you have to change the settings for the path in the IPython config.Phenomenal
Thanks for explaining, @JamieMarshall , are you specifically trying to affect "where Python looks for modules" i.e. the sys.path as described here (you mentioned "all my import statements"); which may be a different question than the current directory (i.e. the os.getcwd()). But , I defer to you, sounds like you figured it out modifying the IPython configBrookes
I was using Anaconda and this solution worked from the anaconda Powershell Prompt cd into the directory Then jupyter notebookGale
E
198

I am on Windows 10 but same version of Anaconda.

  1. Click on the Start Menu, then All Programs (just Programs for Win10)
  2. Click on the Anaconda3 folder; mine is Anaconda3 (64-bit)
  3. In there you should see Jupyter Notebook. If you have a virtual environment installed, it will be followed by the environment name like this: Jupyter Notebook (env)
  4. Right-click Jupyter Notebook entry and navigate to More => Open File Location
  5. Right-click the correct Jupyter Notebook entry, then click on Properties
  6. Enter a path in the Start in: box; if the path has spaces in it, you must enclose it in double quotes
  7. Delete "%USERPROFILE%" at the end of the executable path

User navigating to Anaconda3 folder (in Windows ; in AppData), editing properties of "Jupyter Notebook" shortcut, to change its "Start in" command to point to a directory where you want Jupyter to start

Escarpment answered 5/4, 2016 at 17:41 Comment(13)
I exactly did these, changed the "Start in" path. But still when I double click on the shortcut, it opens in my home directory. Crazy! do you have any suggestions?Hyksos
@Hyksos Double-check that it is the correct path, that the path exists, and if it has spaces in it then you enclosed the whole path in quotes.Escarpment
I have the same issue.Include
It doesn't work on windows 10. The path exists and enclosed, but yet it starts at the original folder.Boxboard
Add your path in the "Destination" box, after jupyter-notebook-script.pyPapillose
Yes, you have to also delete "%USERPROFILE%" at the end of the executable pathGoldstone
@Escarpment I've found a solution that worked for me (see below for my answer to this question).Boxboard
I made copies of the Jupyter shortcut link for each of the different directories I wanted to work in. Then edited each one's "Start in" properties to the relevant path, deleted the "%USERPROFILE%" at the end end of the "Destination" properties, and added in the same relevant path in quotes to the end of the "Destination" properties. This has worked for me in Windows 10 using Anaconda.Solatium
On my machine, the Target was too long and was corrupted when I edited the shortcut. Setting the target to C:\Users\josiahyo\AppData\Local\Continuum\anaconda3\python.exe C:\Users\josiahyo\AppData\Local\Continuum\anaconda3\Scripts\jupyter-notebook-script.py fixed the problem for me.Innovate
this solution works fine, only that you need to change the backslash in your path (that you might have copied from the win10 filesysterm) into slash to avoid character escape problem. Anyway, the configuration method @shahar_m suggested is the most elegant one to get what you want and even moreAerosol
What is supposed to be in the "Target:" field?Octonary
I tried the same steps in Window 10, deleting the "%USERPROFILE%" at the end of the executable path is important else it will continue show the old pathDance
If I add my path inside quotation instead of "%USERPROFILE%", the notebook opens in my path. You must pay attention that your path must not be long, otherwise, Windows 10 clips your path and it is not going to work.Unciform
P
155

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:

  1. In a Windows File Explorer or on the desktop, Right click > New > Shortcut

  2. Enter the following location and click next:

jupyter notebook --notebook-dir="C:/Your/Desired/Start/Directory/"

  1. Enter a name for your shortcut and finish

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:/"

Pendleton answered 4/8, 2017 at 20:35 Comment(3)
I think this is the best answer. The --notebook-dir flag works for me on mac and linux.Arabelle
By several parsecs the most useful answer when Jupyter was installed using pip (and the mysterious anaconda shorcut doesn't exist).Frangible
Best answer by far!Thetes
V
59

I just had the same problem and tested the methods mentioned above. After several trials, I realized that they are partially correct and are not the complete solution. I tested the below in Windows 10 and Anaconda 4.4.0 with python 3.6.

There are two ways to do even though they have only very small difference. Follow the way marneylc suggested above: i.e.

1) Open "Anaconda Prompt" and type jupyter notebook --generate-config

2) You find the file in C:\Users\username\.jupyter\jupyter_notebook_config.py

3) Change the line of #c.NotebookApp.notebook_dir = '' to c.NotebookApp.notebook_dir = 'c:\test\your_root\'

4) Then, go to the shortcut of Jupyter Notebook located in C:\Users\User_name\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)

5) Do the right click and go to the Properties

6) In the Target field, remove %USERPROFILE% as stenlytw suggested above.

7) Then, In the field of Start in, type the same directory of c:\test\your_root\ in jupyter_notebook_config.py

8) Done!

As the simpler way, after step 3, go to C:\Users\User_name\Anaconda3\Scripts

4-2) You can see the file of jupyter-notebook.exe and click it.

5-2) Then, the Jupyter start the folder you specified in jupyter_notebook_config.py. So make the shortcut of this file.

6-2) Done.

Vallejo answered 9/6, 2017 at 17:32 Comment(6)
Actually, all you needed to do after 1-3 was edit your Juypiter shortcut to remove %USERPROFILE%.Vermiculite
Did not work for me: the folder C:\Users\User_name\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit) does not exist in my computer, and clicking jupyter-notebook.exe opens a notebook in the directory where jupyter-notebook.exe is, not in the directory I specified in 'jupyter_notebook_config.py'Biagi
your solution is perfect (steps 1-3)Ephod
Use 'c:/test/your_root/' rather than 'c:\test\your_root\' in step 3 to avoid the backslash escape sequence.Hampton
@SanderHeinsalu To find the right path (Windows 10) click the windos button in the left bottom corner, type "Jupyter Notebook" and right click the upcoming application. Then you can open the file location.Ylem
HELP!!!!! Now when I go to start and click on jupyter notebook it opens and closes instantly!Imaimage
R
42

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: enter image description here

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.

Rectify answered 16/7, 2018 at 14:13 Comment(7)
Perfect.. it worked nice.. and its simple.. i can say its best answerImpress
Of all the methods here, this is the one that worked for me. Although, in my case, I had to use forward double slashes // instead of double back slash (\)Spheroidicity
Works as of 31st Dec 2020.Apivorous
works for me in Windows 10. Nice and easy. ThanksBaecher
Also make sure indentation is removed.Hygrostat
works for me on Windows 11! thanks!Unattended
Worked like a charm!Bidwell
B
37

You can change the configuration from conda command line:

  • run anaconda command prompt
  • run jupyter notebook --generate-config
  • a directory .jupyter/ should have created in your home with a file jupyter_notebook_config.py
  • uncomment and edit the field c.NotebookApp.notebook_dir

credit to Clement https://groups.google.com/a/continuum.io/forum/#!topic/anaconda/gqRwT_SxGBw

Boxboard answered 25/12, 2016 at 13:38 Comment(3)
Uncommenting is, indeed, an important step.Pianette
Confirm that this works for me on Windows 10 and is probably the simplest solutionWhap
Appears to be the same as the earlier, accepted answer.Hygrostat
C
30

I'm using windows 7 (64 bit) with Anaconda2. In the start menu, right click Jupyter Notebook -> Properties. In the Target field, change %USERPROFILE% to your new "D:\path".

                         jupyter

Constanta answered 22/5, 2017 at 4:35 Comment(2)
I am using Anaconda 3 and Windows 10 and this answer is almost correct for that combo -- I used "E:/" rather than "D:\new path". IMPORTANT NOTE: that is a "forward slash", not a "backslash", even though this is Windows. I left my "Start in:" field alone.Architecture
What is supposed to be in the "Target:" field?Octonary
L
24

For Windows 10:

  1. Look for Jupiter notebook shortcut (in Start menu>Anaconda).
  2. Right click and Properties.
  3. Add the path that you would like (but use / not \ for path) as showed on the screenshot:

enter image description here

Lapierre answered 17/12, 2019 at 19:47 Comment(2)
@Frangible I agree. I am using python from Anaconda only so, I have no answer how to do the same when you install Jupyter via pip. Please post your answer here if you will find solution.Lapierre
Confirm that this works for me on Windows 10 and is probably the simplest solutionThionic
H
12

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.

Windows File Explorer

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).
Anaconda Prompt

Afterward, type 'jupyter notebook' and the Jupyter Notebook will be opened. Anaconda Prompt

Note that the Jupyter Notebook's home page does not list anything as the folder is empty. Jupyter Notebook

Once a Python3 notebook is created, the home page will list the files. Jupyter Notebook

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.

Holley answered 11/9, 2020 at 7:23 Comment(1)
Great! Even better would be to create a bat or shortcut file with jupyter notebook command and drop it into your %AppData%\Microsoft\Windows\Start Menu\Programs so that you can add to the start menu.Hilliard
D
8

This question is quite old and the problem seems to have been solved, but if only to remind myself next time I am facing this problem, here is another solution (tested only on Windows 10, though).

The shortcut for the jupyter notebook (be it from the start menu, a desktop shortcut or pinned to the taskbar) calls a number of Scripts (presumably to initialize the jupyter notebook etc.), which are written in the Target text field from the shortcut's Properties window. Appending

--notebook-dir='C:/Your/Desired/Start/Directory/'

should start the notebook in the specified directory (as @Victor O pointed out, it cannot be a drive, but has to be a folder).
If that doesn't do the trick, it can't hurt to also add the same directory to the Start in field.

Note: I used forward-slashes in the Target field and back-slashes in the Start in field. Feel free to change that up, if you are curious which combinations are working.

Also, this was not my idea, but I forgot where it came from (I checked the shortcut from my previous installation, because I was sure not to have tried anything from this page, but the proposed way from the link the OP provided.). If anyone wants to supply the link, please do so.

Sorry if I can't add any fundamental research to this, but the solution worked for me on four separate systems and is fairly simple to implement.

Dabster answered 1/1, 2017 at 15:39 Comment(0)
B
6

agree to most answers except that in jupyter_notebook_config.py, you have to put

#c.NotebookApp.notebook_dir='c:\\test\\your_root'

double \\ is the key answer

Barogram answered 9/7, 2017 at 13:25 Comment(1)
I like this sort of miraculous help. "double \\ is the key answer". This is the key to nothing, and as many already stated either you can use double quotes which allow simple back slashes, or you can use simple quotes but are required to use forward slashes. Or you can use double backslashes to escape the escape character, as you suggest. If someone already tried the two first solutions without success, then yours won't add anything, just loose time.Frangible
P
6

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.

enter image description here enter image description here

Plastered answered 17/7, 2018 at 12:21 Comment(1)
easy way to open cmd to current directoryLectern
E
5

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

  1. Press start and find Jupter Notebook in the Anaconda Folder
  2. Right click -> More -> Open File location
  3. Right click the Jupyter Notebook short cute -> Properties
  4. Now in target: you will see something at the end that looks like: "%USERPROFILE%/". Replace the contents of %USERPROFILE%/ with your desired DIRECTORY. e.g. "D:\GoogleDrive"

Good Luck

Executor answered 21/7, 2019 at 10:16 Comment(0)
I
5

Open Anaconda Prompt and write to open a notebook folder in G drive jupyter notebook --notebook-dir 'G:' there is no "="

Indefinite answered 12/2, 2020 at 7:0 Comment(1)
Perfect, exactly what I needed on Windows 10! >jupyter notebook --notebook-dir 'R:'Mayman
C
4

A nice tip is to just navigate to your desired start folder in Windows Explorer:

  • click File
  • click Open command prompt
  • then just type "jupyter notebook" and press enter

a web browser should pop up shortly with the correct start folder.

Crabstick answered 4/4, 2017 at 17:15 Comment(3)
Similar to Victor O's answer, I thinkBrookes
it's similar but with a difference that if you first navigate to your desired start folder in Windows Explorer, you avoid the "cd" stepCrabstick
Alternatively, If you hold left shift and right click in the folder it will show "Open command window here " in the context menuPinery
N
4

For Windows users, here is a snippet to let you right click folders and open Jupyter Lab there.

enter image description here

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")

Nerynesbit answered 23/6, 2021 at 1:52 Comment(0)
G
3

You can make windows bat file like this.

D: (your dexired drive)
cd \Your\Desired\Start\Derectory
Jupyter notebook

Save it as 'JupyterNB.bat' (or whatever you like), and double click it.

Geis answered 21/5, 2017 at 0:24 Comment(0)
D
3

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

  1. From Anaconda Navigator
  2. Using the shortcut (name: Jupyter Notebook) to Jupyter Notebook application. In Windows OS it is normally available in the folder: "C:\Users\\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)"

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

  1. Run anaconda command prompt
  2. At the command prompt run "jupyter notebook --generate-config"

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:

  1. Create an environment variable to point to the required folder and use it as parameter
  2. Define the absolute path in the shortcut itself

Follow the below steps: (Note: Replace the text in angle brackets with the actual text)

  1. Locate the shortcut "Jupyter Notebook". When Anaconda was installed for a particular user (during installation the choice selected was for the user only) the shortcut (Name: "Jupyter Notebook", Type: Shortcut) resided in "C:\Users\<USERNAME>\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit)"
  2. Right click on the shortcut and select "Properties"
  3. In the "Target" box locate C:\Users\<USERNAME>\Anaconda3\Scripts\jupyter-notebook-script.py %USERPROFILE%
  4. 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>

  5. 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.

Dibru answered 8/7, 2018 at 17:18 Comment(0)
L
3

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

file location

Step 2: Right click on Jupyter Notebook and go to Properties. Add your directory to Target. Mine was "D:\Education\Machine Learning"

Properties setting

Step 3: Do not launch Jupyter Notebook from Anaconda Navigator. Use the above shortcut instead.

Lori answered 8/10, 2020 at 20:30 Comment(0)
C
2

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.

Cephalization answered 29/7, 2022 at 11:48 Comment(0)
C
1

I've just installed Anaconda on Windows 10 and have been trying to configure Jupyter to open in my specified directory, including updating the Jupyter config file as suggested above. This didn't work. After viewing other threads, I stumbled on file "notebook.bat" in the .anaconda\scripts\ folder. This launches Jupyter. I took a copy of the .bat file into the folder I want to work in, ran it, and voila - Jupyter launches in that folder and I no longer see every folder on my PC, just the one I want. One desktop shortcut later and I'm a happy 'non-techy'. I hope this helps.

Commons answered 22/3, 2017 at 18:54 Comment(0)
C
1

After many tries I have done it. I have mentioned the easiest steps below:

  1. Right click on the jupyter launcher icon from start menu or desktop or anaconda navigator

  2. 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

  3. 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.

Celebrant answered 4/11, 2017 at 10:47 Comment(0)
T
1
  • Try to navigate to folder from which you want to run the jupyter notebook files.
  • Right click in the explorer and click on Open in Terminal enter image description here
  • Then type the command jupyter notebook to run the Notebook from the desired location. enter image description here enter image description here
Tatty answered 14/7, 2018 at 18:57 Comment(0)
R
1
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

Roi answered 16/12, 2019 at 9:30 Comment(0)
R
1

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

Repetitious answered 27/4, 2021 at 4:12 Comment(0)
W
1

In case someone still looking for an answer/ other options. Here what works for me best.

  1. Create a .bat file.

  2. 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

  3. 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.

  4. Double click .bat file to launch jupyter notebook on the intended path.

enter image description here

Woolsey answered 16/4, 2022 at 2:26 Comment(1)
thanks this is what i was looking for.Octangular
M
1

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

  1. open terminal from anaconda using the green play button. choose any environment you like
  2. Type cd /d d: #this will take you to D drive along with your env
  3. then you will have two options a. if you want to open jupyter notebook just type jupyter notebook --notebook-dir=d: b. if you want to open jupyter lab just type jupyter-lab This works fine in win 11. N.B: this works for me easily. but i already installed my anaconda in D drive Type jupyter-lab
Mallon answered 15/5, 2023 at 0:49 Comment(0)
K
0

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.

Koan answered 5/11, 2018 at 15:23 Comment(0)
F
0

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 #

Farrago answered 9/11, 2018 at 6:2 Comment(0)
D
0

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%

jupyter-notebook shortcut

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.

Doubleminded answered 27/1, 2019 at 9:20 Comment(0)
P
0

The Best and Easiest way is stated in the jupyter begineers guide : [https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html] It has solution of Windows and Mac , solution for Mac is also applicable for Ubuntu or any linux distro.

Hope it was helpful . Did try to add this as a comment but dint have sufficient reputation points for that .

Pillage answered 5/3, 2020 at 11:5 Comment(4)
It seems to be a broken link.Experimentalism
@Experimentalism I have updated the link url. Please check now if this helps with the issue you are facing.Pillage
No, it takes me up a site that does not exist, apparently.Experimentalism
jupyter-notebook-beginner-guide.readthedocs.io/en/latest/… the "]" is in the URLMascara
P
0

Easy way!

1 - Type jupyer notebook in start menu

1

2 - Make shortcut on desktop of jupyter notebook ( Right click mouse!)

2


3 - Only drag and drop your favorite folder in the shortcut

Pigsty answered 14/4, 2020 at 18:37 Comment(1)
I am sorry, on Windows 10, dragging a folder on top of the "Jupyter" shortcut just creates a shortcut to that folder.Mayman
F
0

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.

Frangible answered 26/10, 2020 at 21:58 Comment(0)
U
0

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 🙂

Unnatural answered 30/11, 2021 at 21:49 Comment(0)
W
0

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

  1. The default behaviour of browser redirection needs to be stopped, hence you should set c.NotebookApp.use_redirect_file = False
  2. The set your preferred working directory; in my case I'm using a mounnted drive so c.NotebookApp.notebook_dir ="/mnt/<mount_point>/<Full-path of directory, using / and no : >/"

This enables the notebook to seamlessly start on your preferred Win directory.

Woodworker answered 13/9, 2022 at 7:0 Comment(0)
P
0

Above answers is not work and too complicated for someone who use Anaconda and Window:

  1. Go to C:\Users\username.jupyter\

  2. create a file: jupyter_server_config.json (For lab) or jupyter_notebook_config.json (For notebook)

  3. json content:

    For lab:

    {
        "ServerApp":{
         "root_dir": "your workspace directory"
        }
     }
    

    For notebook:

    {
         "NotebookApp": {
             "notebook_dir": "your workspace directory"
         }
     }
    
  4. 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

Pursuivant answered 20/6, 2023 at 5:45 Comment(0)
P
0

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!

Pentachlorophenol answered 11/4 at 7:27 Comment(0)
A
-1
[1]  cd e:

Test it by:

[2] pwd
Allantoid answered 19/11, 2020 at 12:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.