pyfilechoose
R's file.choose(), reimplemented for Python.
In R, file.choose() opens a file picker and returns the path you select.
pyfilechoose gives you the same one-liner in Python, with no GUI boilerplate
and no leftover Tk windows.
It uses tkinter from the standard library, so it has no third-party
dependencies.
📖 Full documentation: https://Pinto-Katende-Jonathan.github.io/pyfilechoose/ (installation, usage, API reference, internals, and troubleshooting).
Installation
With pip:
pip install pyfilechoose
With uv:
# Add it to your project
uv add pyfilechoose
# ...or install it into the current environment
uv pip install pyfilechoose
# ...or run a one-off script that uses it, no install needed
uv run --with pyfilechoose your_script.py
On Linux, tkinter ships with most Python builds but may need to be installed
separately, e.g. sudo apt install python3-tk.
Usage
Pick a single file
from pyfilechoose import file_choose
path = file_choose()
print(path) # absolute path of the file you selected
With pandas (the classic R workflow)
file_choose() returns a path string, so it works with any function that takes
a file path, including pd.read_csv:
import pandas as pd
from pyfilechoose import file_choose
# Just like df <- read.csv(file.choose()) in R
df = pd.read_csv(file_choose())
You can still pass the usual pandas options, and filter the picker to CSVs:
df = pd.read_csv(file_choose(filetypes=[("CSV files", "*.csv")]), sep=";")
Filter file types and set a starting directory
path = file_choose(
title="Pick your dataset",
filetypes=[("CSV files", "*.csv"), ("All files", "*.*")],
initialdir="~/Documents",
)
Pick several files at once
from pyfilechoose import files_choose
paths = files_choose(filetypes=[("Images", "*.png *.jpg")])
for p in paths:
print(p)
API
file_choose(*, title="Select a file", filetypes=None, initialdir=None) -> str
Opens a dialog and returns the absolute path of the chosen file.
Raises FileNotFoundError if the user cancels.
files_choose(*, title="Select one or more files", filetypes=None, initialdir=None) -> list[str]
Same as above but allows multiple selections; returns a list of absolute paths.
Raises FileNotFoundError if nothing is selected.
| Argument | Type | Description |
|---|---|---|
title |
str |
Title of the dialog window. |
filetypes |
list[tuple[str, str]] | None |
(label, pattern) pairs, e.g. [("CSV", "*.csv")]. |
initialdir |
str | None |
Directory the dialog opens in. |
Development
git clone https://github.com/Pinto-Katende-Jonathan/pyfilechoose.git
cd pyfilechoose
With uv, which creates and manages the virtualenv for you:
uv sync --extra dev # set up the environment with dev dependencies
uv run pytest # run the test suite
With pip:
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e ".[dev]"
pytest
License
MIT © Jonathan Katende Pinto
Release files for pyfilechoose 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyfilechoose-0.1.1.tar.gz | 6.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyfilechoose-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.7 kB
Release files / pyfilechoose-0.1.1.tar.gz
| Download URL | pyfilechoose-0.1.1.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68f6c1d109be41433655d6e1923bb4922dab626333ac3afbed900a9c37dc432f
|
|
BLAKE2b-256 checksum How to use checksums |
9caa4f212b8d268cda39750d57dac01cfbee9618bd6ed36f9ae6b211089e063f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / pyfilechoose-0.1.1-py3-none-any.whl
| Download URL | pyfilechoose-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
953f1ab61149ad46b26579f1a19c93d5070af4e41eb3161317d5e679f1ca5c29
|
|
BLAKE2b-256 checksum How to use checksums |
0a9a695f945d74005eb68e76a9605ded6ff9dda3ea1f7a54e222a9e1f3acf5c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|