Registry / web-framework / ipyfilechooser

ipyfilechooser

JSON →
library0.6.0pypypi✓ verified 84d ago

IPyFileChooser is a Python file chooser widget designed for use in Jupyter/IPython notebooks, integrating with `ipywidgets`. It allows users to interactively select file paths and filenames. The library is actively maintained, with its latest stable version 0.6.0 released in September 2021.

pip install ipyfilechooser
INSTALL
IMPORT
SIG · IPYFILECHOOSER
I
ipyfilechooser
web-frameworkpythonv0.6.0
Install
5.1s avg
Import
1834ms
Disk
78MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 1.939s · 85.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 5.1s · import 1.730s · 86MB
78MB installed
● package 78MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FileChooser
from ipyfilechooser import FileChooser

This quickstart demonstrates how to initialize and display the `FileChooser` widget in a Jupyter environment. It sets a default path, applies a file filter, and shows how to access the selected file properties. An example of registering a callback function for dynamic responses to user selections is also included.

import os from ipyfilechooser import FileChooser from IPython.display import display # Get the current working directory as the default path current_dir = os.getcwd() # Create and display a FileChooser widget # You can specify a default path, filename, and filter patterns fc = FileChooser(current_dir, title='Choose a file:') fc.filter_pattern = ['*.txt', '*.csv'] # Example: filter for text and CSV files display(fc) # To access the selected path and filename after user interaction # For example, after a button click or callback # print(f"Selected Path: {fc.selected_path}") # print(f"Selected Filename: {fc.selected_filename}") # print(f"Full Selected File: {fc.selected}") # Example of using a callback function def on_selection_change(chooser): print(f"Callback triggered! Selected: {chooser.selected}") fc.register_callback(on_selection_change)
Debug
Known issues
breakingIn `v0.6.0`, the `use_dir_icons` property was replaced by `dir_icon` and `dir_icon_append` for customizing folder icons. Direct usage of `use_dir_icons` will result in an `AttributeError`.
fix
Update your code to use `fc.dir_icon = 'icon_string'` (e.g., '📁') and `fc.dir_icon_append = True/False` instead of `use_dir_icons`.
affects: >=0.6.0
gotchaFor the widget to display correctly in Jupyter environments (Notebook or Lab), `ipywidgets` extensions must be properly enabled. In JupyterLab, a rebuild might be necessary after installation.
fix
Ensure `ipywidgets` is installed and extensions are enabled. For Jupyter Notebook: `jupyter nbextension enable --py --sys-prefix widgetsnbextension`. For JupyterLab: `jupyter labextension install @jupyter-widgets/jupyterlab-manager` followed by `jupyter lab build`. In Docker contexts, building JupyterLab inside the Dockerfile is often essential.
affects: All versions
gotchaSince `v0.4.4`, `filter_pattern` values are treated as case-insensitive. This behavior might differ from expectations on case-sensitive file systems if strict case matching is desired.
fix
Be aware that `filter_pattern` will match regardless of case. If strict case-sensitive filtering is required, apply an additional programmatic filter after `fc.selected_filename` has been retrieved.
affects: >=0.4.4
deprecatedIf using `ipywidgets.interact` with `ipyfilechooser`, the interact functionality might not update as expected due to significant changes in `ipywidgets` since `ipyfilechooser`'s last major updates.
fix
Consider using `ipywidgets.interactive_output` or manually connecting a callback function using `fc.register_callback(my_function)` or `fc.observe(my_function, names='selected')` for more robust interaction.
affects: Potentially all versions when used with recent `ipywidgets`
Errors
Common errors & fixes
Failed to load model class 'VBoxModel' from module '@jupyter-widgets/controls' (or widget simply not displaying).
Jupyter Notebook/Lab extensions for ipywidgets are not correctly installed or enabled, or JupyterLab needs a rebuild.
fix
For Jupyter Notebook: `jupyter nbextension enable --py --sys-prefix widgetsnbextension`. For JupyterLab: `jupyter labextension install @jupyter-widgets/jupyterlab-manager` and then `jupyter lab build`. In Docker environments, building JupyterLab within the Dockerfile often solves this.
AttributeError: 'FileChooser' object has no attribute 'use_dir_icons'
Attempting to use the `use_dir_icons` property which was removed in `v0.6.0`.
fix
Use `dir_icon` and `dir_icon_append` instead. Example: `fc.dir_icon = '📁'` and `fc.dir_icon_append = True` to customize folder icons.
FileNotFoundError: [Errno 2] No such file or directory: '/non_existent_path'
The `default_path`, `sandbox_path`, or other path provided to `FileChooser` does not exist or is not accessible by the Jupyter kernel's user.
fix
Verify that the specified path exists and has appropriate read/write permissions for the user running the Jupyter kernel. Use `os.path.exists()` to check programmatically before initializing `FileChooser`.
Upgrade
Version history
0.6.0latest on PyPI · released Sep 15, 2021
Audit
Dependencies
ipywidgetsrequiredCore dependency for Jupyter/IPython widget functionality.
Agent activity
4 hits · last 30 days
node
4
Resources