Skip to content

how to run notebook from any folder on computer #848

Open

Description

@Sandy4321

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

Activity

  1. stonebig commented on Apr 26, 2020

    @stonebig
    Contributor

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

  2. stonebig commented on Apr 26, 2020

    @stonebig
    Contributor

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

  3. Sandy4321 commented on Apr 26, 2020

    @Sandy4321
    Author

    so no way to run from command line
    something like this

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

  4. stonebig commented on May 1, 2020

    @stonebig
    Contributor

    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"
    
  5. Sandy4321 commented on May 1, 2020

    @Sandy4321
    Author

    unbelievable , so complicated...

  6. stonebig commented on May 1, 2020

    @stonebig
    Contributor

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

  7. BerlXIII commented on Jun 21, 2020

    @BerlXIII

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

  8. joeheaven commented on Aug 15, 2020

    @joeheaven

    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.

  9. ericpre commented on Nov 22, 2020

    @ericpre

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

  10. BerlXIII commented on Nov 22, 2020

    @BerlXIII

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

  11. e-d-n-a commented on Feb 10, 2021

    @e-d-n-a

    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.

  12. stonebig commented on Feb 13, 2021

    @stonebig
    Contributor

    trying something in next build, with this that may work

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

  13. coimbrarodrigo commented on Mar 20, 2023

    @coimbrarodrigo
    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

  14. bb4245 commented on May 16, 2023

    @bb4245

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions