Reputation: 2726
After installing Anaconda, the Jupyter notebook shortcut works fine. Other stackoverflow answers have indicated that you can change the default working directory by changing the "Start In:" field in the shortcut properties. However, if Anaconda is installed in the suggested folder for single users C:\Users\whshg0\AppData\Local\Continuum\Anaconda3\
, then the Target
field of the shortcut gets truncated when you edit the Start in
field. Example:
C:\Users\user01\AppData\Local\Continuum\Anaconda3\python.exe C:\Users\user01\AppData\Local\Continuum\Anaconda3\cwp.py C:\Users\user01\AppData\Local\Continuum\Anaconda3 "C:/Users/user01/AppData/Local/Continuum/Anaconda3/python.exe" "C:/Users/user01/AppData/Loc
al/Continuum/Anaconda3/Scripts/jupyter-notebook-script.py"
gets truncated. After you click ok, Jupyter Notebook will no longer open.
What is a fast way to rebuild the Jupyter Notebook shortcut so the Target
is not limited to the 255 character limit?
Upvotes: 18
Views: 9978
Reputation: 101
I installed miniconda instead of Anaconda because i was tired of anaconda crashing while updating. So anaconda prompt and jupyter notebook shortcuts had to be built manually.
For Anaconda Prompt, the shortcut:
C:\Windows\System32\cmd.exe "/K" "%Localappdata%\Continuum\miniconda3\Scripts\activate.bat"
For Jupyter notebook, the shortcut:
%localappdata%\Continuum\miniconda3\python.exe %LocalAppData%\Continuum\miniconda3\cwp.py %LocalAppData%\Continuum\miniconda3 "%LocalAppData%\Continuum\miniconda3\python.exe" "%LocalAppData%\Continuum\miniconda3\Scripts\jupyter-notebook-script.py"
(Replace miniconda3 with Anaconda3). Pointing to jupyter-notebook.exe as people suggested above did not work unless I was an activated environment, which I was not with a desktop shortcut.
Unfortunately setting the Start In field did not open jupyter in that folder, so maybe step 2 is @Bellaiche's suggestion.
I followed the instructions here to set the Jupyter startup folder: How to change the Jupyter start-up folder.
Added the shortcuts to %appdata%\Microsoft\Windows\Start Menu\Programs\Anaconda3 just to have them on the start menu.
Upvotes: 3
Reputation: 61
The problem was resolved. The shortcut was the issue.
I had to manually change the "Shortcut target" to the following:
C:\Users\'yourusername'\AppData\Local\Continuum\Anaconda3\Scripts\jupyter-notebook.exe
Upvotes: 0
Reputation: 503
I have tried to shorten path by defining my own %anaconda3% variable but my prompt opens and closes within 1 second if i ever edit the target
or start in
fields. of shortcut properties.
According to https://medium.com/@joelclay/access-your-jupyter-notebook-running-on-windows-10-from-any-computer-427bb06309ce
the contents of target are
C:\Users\joel\Anaconda3\python.exe
C:\Users\joel\Anaconda3\cwp.py
C:\Users\joel\Anaconda3
“C:/Users/joel/Anaconda3/python.exe”
“C:/Users/joel/Anaconda3/Scripts/jupyter-notebook-script.py”
I am careful to leave space between the lines and see that last 2 of them are strings with reversed slashes.
Finally my hack was to create a .bat file containing %anaconda3%\scripts\activate.bat & jupyter notebook
and put this bat file in my jupyter shortcut target so it does the same thing as opening Anaconda Prompt and typing jupyter notebook
Upvotes: 0
Reputation: 651
Change c.NotebookApp.notebook_dir = ''
to desired directory.
It will work from Anaconda prompt, but will not with a shortcut. Originally shortcut is too big, that big, that it gets truncated. Actually with jupyter running we don't need cwp.py because the paths assigned there are useless in our case. Change the target of a shortcut to:
C:\Users\USER\AppData\Local\Continuum\Anaconda3\python.exe "C:/Users/USER/AppData/Local/Continuum/Anaconda3/Scripts/jupyter-notebook-script.py"
Change USER
to user on your computer, don't forget to change backslash to forward slash in an argument.
Upvotes: 0
Reputation: 617
FYI I found another issue with the shortcut on Windows 7. The Target
string of the Jupyter Notebook start menu item had a %HOME%
argument at the end. (a) There is no %HOME%
, but there is a%HOMEPATH%
, so change it to that if you want to start in your home directory. (b) An alternative way to specify the start up directory is to use the Start In
field in the Properties dialog box (http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html). To do it the latter way, remove the final path argument from Target
.
Upvotes: 1
Reputation: 71
In Environment variables create System variable Anaconda3 (or other name) with the value:
C:/Users/user01/AppData/Local/Continuum/Anaconda3
Then substitute first 3 entries of:
C:/Users/user01/AppData/Local/Continuum/Anaconda3
in Shortcut -> Target with %Anaconda3%
. This will make the target line length < 255
.
Upvotes: 7
Reputation: 46
The cleanest way I found to change the default working directory is to edit the cwp.py file in the Anaconda folder as following (at the end of the file):
Replace this line:
os.chdir(documents_folder)
with the folder you want to start in:
os.chdir("C:\\Private_Files\\MachineLearning")
Upvotes: 3
Reputation: 1528
I was able to remake the shortcut by pointing the shortcut to:
C:\Users\user01\AppData\Local\Continuum\Anaconda3\Scripts\jupyter-notebook.exe
I lost the icon but I'm sure with some searching I can find it again.
Upvotes: 11