You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
launch() cannot locate files with spaces in the name on Windows #2994
When a Windows program uses click.launch(some_path, locate=True) and some_path contains spaces, then Windows Explorer opens showing the user's Documents folder and not the specified file.
Dispatching the call to powershell and not cmd seems to fix the problem.
Reproduction
# Prepare and enter the virtual environment
mkdir click-demo
cd click-demo
python -m venv --upgrade-deps .venv
.\.venv\Scripts\activate.ps1
# Check versions
pip -V
# pip 25.1.1 from X:\scratch\click-demo\.venv\Lib\site-packages\pip (python 3.11)# Install click
pip install click
# Check environment
pip list
# Package Version# ---------- -------# click 8.2.1# colorama 0.4.6# pip 25.1.1# setuptools 80.9.0
click-demo.py
importpathlibimportsubprocessimportclick# No spaces in this pathroot_folder=pathlib.Path("C:\\Users\\Public")
# No spaces in this pathsucceeding_folder=root_folder/"click-demo"succeeding_folder.mkdir(exist_ok=True)
click.launch(str(succeeding_folder), locate=True)
# Path has spaces!failing_folder=root_folder/"click demo"failing_folder.mkdir(exist_ok=True)
click.launch(str(failing_folder), locate=True)
# Wrap with powershellsubprocess.run(
[
"powershell",
"-Command",
f"explorer /select,{failing_folder!s}",
],
check=True,
)
changed the title [-]Windows: `click.launch()` cannot locate files with spaces in the name for version 8.2.1[/-][+]`launch()` cannot locate files with spaces in the name on Windows[/+]on Jul 4, 2025
Activity
[-]Windows: `click.launch()` cannot locate files with spaces in the name for version 8.2.1[/-][+]`launch()` cannot locate files with spaces in the name on Windows[/+]davidism commentedon Jul 4, 2025
No need to use Powershell. The argument to
/selectneeds to be quoted, as described here: https://www.geoffchappell.com/studies/windows/shell/explorer/cmdline.htm. Something like the following will probably work:f'/select,"{_unquote_file(url).replace('"', '""')}"'Fix explorer /select with spaces on Windows (pallets#2994)
gilangjavier commentedon Mar 23, 2026
fix: quote explorer /select path on Windows in launch(locate=True)
Add missing changelog entry
Add missing changelog entry