Git Product home page Git Product logo

nbopen's Introduction

Open notebooks from the command line

nbopen looks for the nearest running notebook server - if it finds one, it opens a web browser to that notebook. If not, it starts a new notebook server in that directory.

Installation:

python3 -m pip install nbopen

Usage:

nbopen AwesomeNotebook.ipynb

To integrate with your file manager, so you can double click on notebooks to open them, run:

  • Linux/BSD: python3 -m nbopen.install_xdg
  • Windows: python3 -m nbopen.install_win
  • Mac: Clone the repository and run ./osx-install.sh

nbopen's People

Contributors

ajasja avatar artwr avatar bryango avatar cjermain avatar flying-sheep avatar gamdow avatar jan-glx avatar jfeist avatar senderle avatar stefanv avatar takluyver avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nbopen's Issues

nbopen installs without extension???

image

Uninstalling nbopen-0.3:
  c:\python\python27_32b\lib\site-packages\nbopen-0.3.dist-info\description.rst
  c:\python\python27_32b\lib\site-packages\nbopen-0.3.dist-info\installer
  c:\python\python27_32b\lib\site-packages\nbopen-0.3.dist-info\metadata
  c:\python\python27_32b\lib\site-packages\nbopen-0.3.dist-info\metadata.json
  c:\python\python27_32b\lib\site-packages\nbopen-0.3.dist-info\record
  c:\python\python27_32b\lib\site-packages\nbopen-0.3.dist-info\top_level.txt
  c:\python\python27_32b\lib\site-packages\nbopen-0.3.dist-info\wheel
  c:\python\python27_32b\lib\site-packages\nbopen.py
  c:\python\python27_32b\lib\site-packages\nbopen.pyc
  c:\python\python27_32b\scripts\nbopen
Proceed (y/n)?

Autosave Error on Windows

Using a windows 7 box, after opening the notebook with nbopen and making a change I get the following notice and error:

image

and "Unexpected error while saving file: Desktop\etc\etc to notebook.ipynb [Errno 2] No such file or directory: 'C\Users\ipynb_checkpoints\username\Desktop\etc\etc\notebook-checkpoint.ipynb

It appears the autosave is placing the ipynb_checkpoints in the wrong location of the path.

new release

jupyter is out and nbopen 0.2 still uses ipython only

TypeError in find_best_server

Using nbopen on some of my notebooks fails with the following (OSX 10.9.4, Homebrew Python 2.7.6):

-> % nbopen 2_Scientific-Computing-with-Python.ipynb 
Traceback (most recent call last):
  File "/usr/local/bin/nbopen", line 3, in <module>
    main()
  File "/usr/local/lib/python2.7/site-packages/nbopen.py", line 46, in main
    nbopen(args.filename, args.profile)
  File "/usr/local/lib/python2.7/site-packages/nbopen.py", line 23, in nbopen
    server_inf = find_best_server(filename, profile)
  File "/usr/local/lib/python2.7/site-packages/nbopen.py", line 16, in find_best_server
    default=None)
TypeError: max() got an unexpected keyword argument

nbopen -p uses only default profile.

When running nbopen -p my_profile Notebook.ipynb, a new notebook server is started using profile_default rather than profile_my_profile. This is probably because line 37 for nbopen.py does not pass the --profile flag:

                                        argv=[],  # Avoid it seeing our own argv

Instead, it should probably be something like

                                        argv=['--profile', profile],  # Avoid it seeing our own argv

It appears that nbopen is careful to only share existing servers if they are running the same profile, so this is only an issue when starting a new nbserver.

Open without Browser

Hello,

I'm trying to modify your code a little bit to launch a notebook kernel without the browser. It appears that just setting cfg.NotebookApp.open_browser = False doesn't do the trick. Could you point me in the right direction on how to launch one of these kernels sans web browser?

uninstall from windows file manager

Hello, Is there an easy way to uninstall the integration with windows file manager, I uninstalled with pip but, it continues to run when I click a notebook in my file system.
thanks

python.exe window won't close on windows 10

I followed the instructions to integrate with my file manager on Windows 10 by running:

python3 -m nbopen.install_win

It works and I am able to double-click open .ipynb files in a jupyter notebook. Doing so opens a python.exe blank terminal window (running it I presume). Unfortunately this window never closes, even after I close and halt the notebook, close the browser tabs, CNTRL + C in the anaconda prompt, close my browser. I have to restart my whole system to close those pesky python windows.

Default browser

It would be nice if nbopen opens the notebook via the browser set in the jupyter profile:
c.NotebookApp.browser = instead of the users default browser.

In order to not mix up my notebooks with my other browsing tabs, I use chromium for the notebooks, and firefox for the other activities.

As I quick fix on unix, I changed in nbopen.desktop the exec line:

Exec=env BROWSER=chromium-browser nbopen %f

To integrate with your file manager...

Hi all
I'm new in Linux, and a beginner i Python, so I'm not confident with installing programs via command line..
I followed your instructions in the README, but I can't undertand the last statement:

Ensure that nbopen is on the profile path (not just terminal, e.g. .profile not .bashrc)

I mean: where should I check it, and, just in case, what should I do?
Thank you

500 : Internal Server Error

I have installed nbopen on a Windows 10 machine and then double clicked on a ipynb file. a new tab opens up in a browser and it has the Jupyter logo in the upper left but the notebook doesn't actually open. All I get is "500 : Internal Server Error" where the notebook should be.
nbopen tries to open the url: http://localhost:8888/notebooks/Hello%20World.ipynb
The correct url is : http://localhost:8888/notebooks/local/Hello%20World.ipynb

I'm pretty sure that this is because I use the Jupyter Drive extension for Jupyter, particularly in "mixed" mode. This makes the URL a bit different. However, I have no idea how to customize or change the URL, so I'm not sure how to handle this. Any ideas?

nbopen doesn't create file it it doesn't exist

e.g.
nbopen foo.ipynb opens the JupyterLab interface if foo.ipynb doesn't exist, instead of creating it.

Ideally, it would create an empty file of that name and then open it with jupyter. I bet the tricky bit is that you have to guess at the format of the file based on the name...

windows additional settings

The Windows setup for nbopen Explorer integration includes only setting the registry keys, I found that this is not enough and file associations have to be set from command line prompt (cmd):

assoc .ipynb=IPYNBFILE
ftype IPYNBFILE="C:\Python\Python27\Scripts\ipython.exe" notebook "%%1"

%% may have to be replaced by % depending on the mode of running the batch script.

For other useful settings for ipython/jupyter notebooks that could be integrated into windows explorer by modifying the registry keys see also:

http://petebachant.me/improving-ipython-notebook-integration-with-windows

Can't run on Windows

For some reason, nbopen doesn't install through setuptools; the 'nbopen' file created in Python\Scripts, with a shebang, is completely useless to Windows.

nbopen has encountered a fatal error

nbopen works from the terminal but I have a problem after I install the mac app using the ./osx-install. Once the installation is complete, I get the following error while opening the app.

image

Server started via nbopen and pythonpath

Warning: This question might be not directly related to nbopen

When jupyter is launched by nbopen (launched by double clicking on a notebook in caja) , it does not have the pythonpath that I set in my bashrc, while bash is my "login terminal".

Any clue what is going wrong or how to debug or for what keywords to search for?

nbopen executable not installed under windows

  1. I first installed nbopen with pip or with distutils.
  2. Then I ran python win-install.py from the source tree
  3. nbopen is not found:
'nbopen' is not recognized as an internal or external command,
operable program or batch file.

Windows 7, Anconda 2.2 64, python 2.7

License file

The package currently lacks a License (or Copying) file containing the license for the package. This makes it hard to distribute in Linux distributions. Please add such a file.

Installed, double clicked on ipynb and got fatal error....

I installed nbopen then tried to double click a jupyter notebook. I have the jupyter notebook open. I got an error in a new window:

"A Python runtime not could be located. You may need to install a framework build of Python, or edit the PyRuntimeLocations array in this application's Info.plist file."

In the console:

GetDYLDEntryPointWithImage(/System/Library/Frameworks/AppKit.framework/Versions/Current/AppKit,_NSCreateAppKitServicesMenu) failed.

Can't integrate with file manager

Hi!

Doing this on Linux (arch), when running

python -m nbopen.install_xdg

I get

xdg-mime: file '/usr/lib/python3.6/site-packages/nbopen/application-x-ipynb+json.xml' does not exist
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.6/site-packages/nbopen/install_xdg.py", line 17, in <module>
    check=True)
  File "/usr/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['xdg-mime', 'install', '/usr/lib/python3.6/site-packages/nbopen/application-x-ipynb+json.xml']' returned non-zero exit status 2.

The contents of /usr/lib/python3.6/site-packages/nbopen/ are

total 56
drwxr-xr-x   3 root root  4096 Jul  2 20:23 ./
drwxr-xr-x 374 root root 24576 Jul  2 20:23 ../
-rw-r--r--   1 root root   120 Jul  2 20:23 __init__.py
-rw-r--r--   1 root root  1287 Jul  2 20:23 install_win.py
-rw-r--r--   1 root root  1111 Jul  2 20:23 install_xdg.py
-rw-r--r--   1 root root    32 Jul  2 20:23 __main__.py
-rw-r--r--   1 root root  2472 Jul  2 20:23 nbopen.py
drwxr-xr-x   2 root root  4096 Jul  2 20:41 __pycache__/

Cheers!

No module named 'notebook'

Hello,

I have installed Jupyter with conda and now trying to install nbopen on my mac. I can open ipython notebook using the command line. However, there is trouble to integrate with the file manager using

./osx-install.sh
Following are the errors:

generating .icns file for mac app...
NOTE: this will produce one warning message, because there is no
1024x1024 icon that could be used to for the 'retina' 512x512 icon
Traceback (most recent call last):
File "py2app_setup.py", line 5, in
import nbopen
File "/Users/nbopen/nbopen/init.py", line 5, in
from .nbopen import main
File "/Users/nbopen/nbopen/nbopen.py", line 7, in
from notebook import notebookapp
ImportError: No module named 'notebook'

404 not found

I've installed nbopen, and when I double-click on a notebook, I get the following error:

404 : Not Found
You are requesting a page that does not exist!

The URL shows the path to the notebook

http://localhost:8888/notebooks/path%5Cto%5Cnotebook%5Cactual_notebook.ipynb

If I remove everything but http://localhost:8888 from the URL, I get a file tree, and I can click on the notebook to start it.

I'm running windows 7 enterprise, service pack 1,
Python 3.6.1 :: Anaconda custom (64-bit)

Any ideas what might be causing this? Thanks in advance.

Consider supporting opening in jupyterlab

I believe quite a bit of machinery should apply to jupyterlab unchanged, specifically finding the best lab server.

Now that jupyterlab has /lab/tree endpoint also opening the notebook (or any other file) in a new lab tab would work.

problems with ./xdg-install.sh

cannot delete issue but... xdg-install.sh. placed nbopen (script) in ~/.local/bin which is not on the/any path. I got things rolling by moving to ~/bin/

nbopen.desktop:There was an error launching the application

In linux mint 17.2 nbopen AwesomeNotebook.ipynb open my notebook but, after integrating it on the file manager (i.e. just running ./xdg-install.sh), clicking on nbopen.desktop I get 'There was an error launching the application' and obviously also double clicking .ipynb files does not work.
Any idea on how to solve it?
thanks

root directory for notebook server

How does nbopen determine if the current notebook file (.ipynb) can be opened in the current notebook server?

e.g. if I have 2 notebook servers opened in 2 directories, can nbopen find whether to launch a third server when opening a new notebook with nbopen command or from explorer?

The issue is that notebook server may not have access to a new notebook, if it is not located in one of its sub-directories.

Kernel/server shutdown

Is there any mechanism in nbopen for server shut-down when opening notebooks via double-click?

The ideal would be detecting when the tab is closed and shutting down the server.

If this is impossible, then a panel applet listing the kernels with the ability to close them would be an alternative.

Can't open outside of HOME

I think it's pretty common for Windows users to have files outside their HOME directories. IPython notebooks already have a trust system, does this "security reason" actually stand?

Open exact directory

I might just want to start a notebook server in a specific directory. Right now, the best I can do is pass that directory, but nbopen might be happy with any server started in a parent directory (or actually, starts with the same string, since the subdirectory computation appears wrong).

Traceback on .ipynb with local symbols

When running nbopen in cmd with russian symbols in name get traceback:
Traceback (most recent call last): File "/usr/local/bin/nbopen", line 11, in <module> sys.exit(main()) File "/usr/local/lib/python2.7/dist-packages/nbopen/nbopen.py", line 52, in main nbopen(args.filename) File "/usr/local/lib/python2.7/dist-packages/nbopen/nbopen.py", line 24, in nbopen server_inf = find_best_server(filename) File "/usr/local/lib/python2.7/dist-packages/nbopen/nbopen.py", line 14, in find_best_server if filename.startswith(si['notebook_dir'])] UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 33: ordinal not in range(128)

Is it problem with my python 2.7 packages or else?

If no russian symbols - notebook starts as expected.

Start notebook server in root VCS directory if found.

I have not fully thought through the implications of this yet, but it could be very handy if nbopen was VCS aware and would start a server at the top level (or a customizable level) of a repository when started in a version controlled project. One particular use case is to include project-specific python_notebook_config.py or python_config.py files in a single location that will automatically apply to notebooks opened within that project. (Presently these will only take effect if ipython is run in the same directory as the config files and I know of no way to specify that config files in preceeding directories should take effect.)

Maybe a good way of doing this would be for nbopen to look for a specific configuration file in the root of a project (either defined as the location of VCS directories like .hg or .git or maybe defined as a top-level python package directory with setup.py. In the latter case, maybe the configuration could be in setup.cfg) which can specify where ipython notebook should be run from or where the configuration files are located (so they don't need to pollute the root directory namespace).

open multiple notebooks with one call to nbopen?

Thanks very much for nbopen.
Simple suggestion: It would be nice to permit opening multiple files (in separate browser tabs) with one call to nbopen, like this:

nbopen foo.ipynb bar.ipynb
nbopen *.ipynb

I expected this to work and was surprised when it gave an error.

While it might seem almost as easy to write

nbopen foo.ipynb; nbopen bar.ipynb
for f in *.ipynb; do nbopen $f; done

these don't actually work because the first call to nbopen may have to open a notebook server, in which case it doesn't terminate until that server is closed. One would have to run the first call in the background.

Also, it is sometimes convenient to have a single command running that mentions a group of related filenames. This can make it easier to use commands like jobs and ps -f and pgrep -f and pkill -f, which list or match the full command.

cannot install from master

pip install git+https://github.com/takluyver/nbopen fails due to flit settings, no setup.py:

C:\Users\denis>pip install git+https://github.com/takluyver/nbopen
Collecting git+https://github.com/takluyver/nbopen
  Cloning https://github.com/takluyver/nbopen to c:\users\denis\appdata\local\temp\pip-a0_6h689-build
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "c:\python\python35_64b\lib\tokenize.py", line 454, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\denis\\AppData\\Local\\Temp\\pip-a0_6h689-build\\setup.py'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\denis\AppData\Local\Temp\pip-a0_6h689-build\

C:\Users\denis>

Unicode errors

When using nbopen to open a notebook with non-ascii characters in the filename, I get this error

abr@pc596:~$` nbopen Projects/scratch/Anbefaling\ Angående\ Inkøb\ af\ Hardware\ til\ Webdanica\ Cluster.ipynb 
Starting new server
Traceback (most recent call last):
  File "/usr/local/bin/nbopen", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/nbopen/nbopen.py", line 52, in main
    nbopen(args.filename)
  File "/usr/local/lib/python2.7/dist-packages/nbopen/nbopen.py", line 43, in nbopen
    argv=[],  # Avoid it seeing our own argv
  File "/usr/local/lib/python2.7/dist-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 656, in launch_instance
    app = cls.instance(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/configurable.py", line 412, in instance
    inst = cls(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 272, in __init__
    SingletonConfigurable.__init__(self, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/config/configurable.py", line 73, in __init__
    super(Configurable, self).__init__(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/traitlets.py", line 995, in __init__
    setattr(self, key, value)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/traitlets.py", line 583, in __set__
    self.set(obj, value)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/traitlets.py", line 557, in set
    new_value = self._validate(obj, value)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/traitlets.py", line 589, in _validate
    value = self.validate(obj, value)
  File "/usr/local/lib/python2.7/dist-packages/traitlets/traitlets.py", line 2051, in validate
    raise TraitError(msg.format(value, self.name, class_of(obj)))
traitlets.traitlets.TraitError: Could not decode '/home/abr/Projects/scratch/Anbefaling Ang\xc3\xa5ende Ink\xc3\xb8b af Hardware til Webdanica Cluster.ipynb' for unicode trait 'file_to_run' of a NotebookApp instance.

KeyError in Python 3.4 under IPython 3 dev

nbopen fails with a KeyError under the current IPython master and Python 3.4:

$ nbopen Sao\ Paulo\ Measles.ipynb 
Traceback (most recent call last):
  File "/usr/local/bin/nbopen", line 3, in <module>
    main()
  File "/usr/local/lib/python3.4/site-packages/nbopen.py", line 49, in main
    nbopen(args.filename, args.profile)
  File "/usr/local/lib/python3.4/site-packages/nbopen.py", line 26, in nbopen
    server_inf = find_best_server(filename, profile)
  File "/usr/local/lib/python3.4/site-packages/nbopen.py", line 14, in find_best_server
    servers = [si for si in notebookapp.list_running_servers(profile=profile) \
  File "/usr/local/lib/python3.4/site-packages/nbopen.py", line 14, in <listcomp>
    servers = [si for si in notebookapp.list_running_servers(profile=profile) \
  File "/usr/local/lib/python3.4/site-packages/IPython/html/notebookapp.py", line 981, in list_running_servers
    if check_pid(info['pid']):
KeyError: 'pid'

Running on OS X 10.10.

Dead kernel on OS X

nbopen open ipynb files from a Finder double click. Great! But... the kernel just die after few seconds.

Have you a hint of what can cause that behaviour and how to solve that?

file manager integration broken?

After installing nbopen (nbopen myfile.ipynb works in terminal), I also ran

Linux/BSD: python3 -m nbopen.install_xdg

Now nautilus changed the icons of .ipynb files but clicking them results in the following error:

Could not display “myfile.ipynb”.
There is no application installed for “IPython notebook” files.
Do you want to search for an application to open this file?

nbopen is in my path in my ~/.profile (PATH="$HOME/anaconda3/bin/nbopen:$PATH"), I'm running close to stock ubuntu 16.04

Did I miss something?

nbopen path

Hi, It appears that double click to open ipynb only works if c.NotebookApp.notebook_dir in jupyter_notebook_config.py is not set (default to $HOME), otherwise double click would open an empty notebook with 404 not found. It seems that nbopen search paths relative to $HOME. Is there a way to configure it so that it interprets paths as relative to notebook_dir ?

OS is Ubuntu 16.04 on two machines, in one I use anaconda, the other just installed with pip.

Thanks.

GUI integration for Mac

Double-click to open a notebook works on Linux and Windows. I'm waiting for a Mac user to come and make it work there too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.