Skip to content

how to run notebook from any folder on computer #848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Sandy4321 opened this issue Apr 26, 2020 · 14 comments
Open

how to run notebook from any folder on computer #848

Sandy4321 opened this issue Apr 26, 2020 · 14 comments
Labels
Procedure Procedure

Comments

@Sandy4321
Copy link

Please help how to run notebook from any folder on computer
the problem is Jupyter Notebook.exe from
e:\WINPYTHON_FULL_apr22\WPy64-3770\Jupyter Notebook.exe

can read only notebooks from
E:\WINPYTHON_FULL_apr22\WPy64-3770\notebooks

so lets say file my_notebook.ipynb located in
E:\my_code

@stonebig
Copy link
Contributor

did you try drag & drop the notebook on jupyterlab icon ?

@stonebig
Copy link
Contributor

with Winpython64-3.8.2.1codb2.exe, you can also try drag & drop the notebook on VSCode icon.

@Sandy4321
Copy link
Author

so no way to run from command line
something like this

Jupyter Notebook.exe E:\my_code\my_notebook.ipynb
?

@stonebig
Copy link
Contributor

stonebig commented May 1, 2020

the icon is doing what is in scripts\winjupyter_lab.bat:

@echo off
call "%~dp0env_for_icons.bat"
cd/D "%WINPYWORKDIR%"
"%WINPYDIR%\scripts\jupyter-lab.exe" %*

so to call E:\my_code\my_notebook.ipynb, you can do:

call "E:\WINPYTHON_FULL_apr22\WPy64-3770\scripts\env_for_icons.bat"
"%WINPYDIR%\scripts\jupyter-lab.exe" "E:\my_code\my_notebook.ipynb"

@Sandy4321
Copy link
Author

unbelievable , so complicated...

@stonebig
Copy link
Contributor

stonebig commented May 1, 2020

maybe they have better ideas on stackoverflow, you may ask there

@BerlXIII
Copy link

Ok, so here's a simple and uncomplicated way of doing this:
-copy the path of the project folder you would like to create your notebook in. Simply click on the path in the windows explorer and copy to clipboard
-open the WinPython Command Prompt in the WinPython folder. I recommend adding the WP Command Prompt to the taskbar (usefull for pip install stuff etc.)
-type cd PASTE and hit enter. By PASTE I actually mean Ctrl+v the path you had copied in step one. Now you've changed the directory to your project's path (cd stands for change directory).
In your example this step means typing cd E:\my_code and enter.
-type jupyter notebook or jupyter lab and hit enter.
Now you've successfully opened jupyter in a directory of your choice.
-create a notebook and start coding ;)

And you should register *.ipynb files to the jupyter notebook/lab app in the winpython directory. Then you can launch the notebook you created earlier by simply klicking on the file.

As you see, it only takes 2 lines in the WP command prompt:
cd E:\my_code and jupyter notebook it's really not complicated at all...

@joeheaven
Copy link

I know that is already old, but I had the same problem. The suggestion by @BerlXIII works, but stil requires you to start something somehwere else.

I threw together some pieces of the available scripts and wrote the following Batch-file called "Start-Jupyter-Here.bat":

@echo off
echo This scipts starts Jupyter from any folder
echo The path to the root of WinPython has to be defined in this script
echo.
rem Path without \ at the end!
set wipypfad=c:\WinPython-64bit-3.6.1.0Qt5
echo We use %wipypfad%
if not exist %wipypfad%\scripts\env_for_icons.bat echo Path not correct! %wipypfad%\scripts\env_for_icons.bat not found! EXIT
if not exist %wipypfad%\scripts\env_for_icons.bat goto :EndHere
echo.
echo Path is correct!
call "%wipypfad%\scripts\env_for_icons.bat"
echo Calling Jupyter ....
jupyter notebook
:EndHere

It is pretty much what was suggested above, but you can copy this batch file into any folder and directly launch Jupyter by double-clicking the batch file in that folder Works on network shares as well.

@ericpre
Copy link

ericpre commented Nov 22, 2020

A slightly different approach may be to use a shortcut in the context menu: https://pypi.org/project/start-jupyter-cm.

@BerlXIII
Copy link

Very cool, @joeheaven's solution works! But I guess @ericpre's solution is even more uncomplicated...

@e-d-n-a
Copy link

e-d-n-a commented Feb 10, 2021

I suggest another "Start_Jupyter [WPy-x64-3760ps2].cmd" to run a Jupyter Notebook-server in the directory of the script:

@ECHO OFF

SET winpydir=C:\WinPython
SET winpy=WPy-x64-3760ps2

CMD /S /C "title Jupyter Notebook Server (%winpy%) && "%winpydir%\%winpy%\scripts\ipython_notebook.bat" %~dp0"

ECHO.
ECHO Server halted.
PAUSE

EXIT /B 0

You should put the script in the root-folder of your notebooks' location and run the script via a shortcut from anywhere.
So, here the folders for the installation and notebooks are fixed, but not the same.
The working directory should be changed from within the chosen notebook.

@stonebig
Copy link
Contributor

stonebig commented Feb 13, 2021

trying something in next build, with this that may work

"winipython_notebook.bat E:\my_code\my_notebook.ipynb"

@stonebig stonebig added this to the 2021-01 Jupyterlab-3.0 milestone Feb 13, 2021
@coimbrarodrigo
Copy link

coimbrarodrigo commented Mar 20, 2023

  1. Open a text editor such as Notepad.

  2. Copy and paste the following code into the text editor:

@echo off
call "%~dp0env_for_icons.bat" %*
cd /d "C:\"
"%WINPYDIR%\scripts\jupyter-notebook.exe" %*
  1. Save the file with a .bat extension, such as "launch_jupyter.bat".

  2. Navigate to the WinPython64-3.11.1\scripts directory.

  3. Move the batch file you created in Step 3 to the scripts directory.

  4. Double-click the batch file to run it.

  5. Jupyter Notebook should launch in the C: drive. From there, you can navigate to any other directory or file on your system.

That's it! You should now be able to launch Jupyter Notebook in the C: drive by running the batch file you created.

~roco

@bb4245
Copy link

bb4245 commented May 16, 2023

This an older query now but I have come across an easier solution while looking through these answers

Open winpython command prompt

cd to folder you want

enter the following in command prompt
jupyter notebook

This will open jupyter in directory specified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Procedure Procedure
Projects
None yet
Development

No branches or pull requests

8 participants