It's 10am. You've downloaded a new dataset — it's sitting in your Downloads folder, you can see it in Finder. You open your Jupyter notebook, write pd.read_csv('sales_data.csv'), and run the cell. Python replies:

FileNotFoundError: [Errno 2] No such file or directory: 'sales_data.csv'

You just looked at it. It exists. This specific frustration is so common in the data science world it borders on a rite of passage — and it happens because of something most beginner guides skip entirely: the working directory.

Quick answer

Use an absolute path to guarantee Python finds your file every time. Two ways to get it fast: hold Option + right-click on the file in Finder → "Copy [filename] as Pathname" (4 steps, native macOS). Or install Pathly and right-click → "Copy Path" (2 steps, always in the context menu without any modifier key).

Why Mac Paths Confuse Python

There are three separate issues that catch people out. They often layer on top of each other, which makes debugging even harder.

1. The working directory problem

When you write open('sales_data.csv') or pd.read_csv('sales_data.csv'), Python looks for the file relative to the current working directory — the folder Python considers "here" at that moment. It does not look in the folder where your script or notebook lives. It looks where Python was started from.

In a Jupyter notebook, the working directory is wherever you ran jupyter notebook or jupyter lab from in Terminal — which is often your home folder (/Users/yourname) or whatever directory you were in when you launched it. If your notebook lives in /Users/yourname/projects/analysis/ but you launched Jupyter from your home folder, a relative path like 'data/sales.csv' looks for /Users/yourname/data/sales.csv, not /Users/yourname/projects/analysis/data/sales.csv.

To check your actual working directory, run this in a notebook cell:

In [1]:
import os
print(os.getcwd())
 
# Output might be:
/Users/priya
# Not /Users/priya/projects/analysis — surprise.

2. The tilde ~ expansion trap

On Mac, ~ is a shorthand for your home directory. In the Terminal, in Finder's address bar, and in most apps, ~/Downloads/sales.csv expands to /Users/yourname/Downloads/sales.csv automatically.

Python's open() does not automatically expand ~. This fails silently — Python looks for a file or directory literally named ~:

# This FAILS — Python does not expand ~
df = pd.read_csv('~/Downloads/sales.csv')
FileNotFoundError: [Errno 2] No such file or directory: '~/Downloads/sales.csv'
 
# Fix with os.path.expanduser:
import os
df = pd.read_csv(os.path.expanduser('~/Downloads/sales.csv'))

3. Spaces in filenames

Python handles spaces in filenames just fine as long as you quote the path correctly in a string — which you always are, since it's a Python string. The issue arises when you copy a path from Terminal, where spaces are escaped with backslashes: /Users/priya/My\ Documents/sales.csv. If you paste that into a Python string as-is, Python sees the backslash as an escape character and gets confused.

The safest approach: wrap paths that might have spaces in a pathlib.Path() object, or use a raw string r"/Users/priya/My Documents/sales.csv". Note that Pathly copies paths as plain POSIX strings without backslash escaping — correct for Python strings, not for shell commands.

Three Real Patterns Data Scientists Use

Pattern 1: Hardcoded absolute path

The simplest fix. Copy the full absolute path from Finder and paste it directly as a string:

# Works reliably on your machine
df = pd.read_csv('/Users/priya/projects/q2-analysis/data/sales.csv')

This works every time and is the fastest path from "file in Finder" to "code that runs." The downside: it breaks the moment anyone else opens your notebook, because their home directory is different. It also breaks if you move the file or rename any folder in the path.

Best for: Quick exploratory work on your own machine. Not great for shared notebooks or code you'll run elsewhere.

Pattern 2: pathlib.Path with Path.home()

from pathlib import Path
 
# Portable — works regardless of username or OS
data_path = Path.home() / 'projects' / 'q2-analysis' / 'data' / 'sales.csv'
df = pd.read_csv(data_path)

This is the "correct" software engineering approach. Path.home() returns the current user's home directory on any OS, so the code is portable. The downside: you still have to type the path structure manually. This is great for scripts you write once and reuse; less practical for fast exploratory notebooks where the path changes every session.

Pattern 3: Right-click → Copy Path → paste as absolute string

For exploratory data analysis where you're loading different files every session, the fastest workflow is:

1

Find the file in Finder

2

Right-click → Copy Path (with Pathly) or hold Option + right-click → "Copy as Pathname" (native)

3

In your notebook, type pd.read_csv(' and paste

4

Close the string with ') and run

The result is an absolute path like /Users/priya/Downloads/sales_q2_final.csv — always correct, regardless of working directory. This is the pattern that actually gets things done during an analysis session.

Jupyter-Specific Tips

A few patterns that specifically help in Jupyter notebooks:

# Check where Jupyter thinks "here" is
import os; print(os.getcwd())
 
# Change working directory to the notebook's own folder
import os
os.chdir(os.path.dirname(os.path.abspath('__file__')))
 
# Or in JupyterLab, use the magic command:
%cd /Users/priya/projects/q2-analysis/
 
# Then relative paths work as expected:
df = pd.read_csv('data/sales.csv')
From Zura's workflow

When doing exploratory data analysis for product decisions at Sophinauta — looking at usage patterns, cohort data, that kind of thing — I'm constantly moving files in Finder, finding the right CSV, and feeding paths into Jupyter. I right-click the file in Finder and copy the path with Pathly, paste it as a string directly into the notebook cell. I also do the same when feeding file references to Claude prompts: file:///Users/zura/data/retention_july.csv — Pathly's "Copy as URL" gives me a file:// URL in one extra click that some AI tools and apps can use directly to open the file.

Working with Files That Have Spaces in the Name

If your file is named something like Q2 Sales Data.csv, the spaces are fine in Python — they're just part of the string. What matters is that you don't accidentally include a backslash-escape in the path (those come from Terminal, not from Finder):

# This is WRONG — backslash from Terminal paste
df = pd.read_csv('/Users/priya/Q2\ Sales\ Data.csv')
 
# This is correct — plain string with spaces
df = pd.read_csv('/Users/priya/Q2 Sales Data.csv')
 
# Also correct — pathlib handles spaces cleanly
from pathlib import Path
df = pd.read_csv(Path('/Users/priya/Q2 Sales Data.csv'))

Pathly copies the plain POSIX path without backslash escaping, which is correct for use in Python strings. The spaces in the filename are preserved as-is and Python handles them without complaint.

One thing Pathly does not do

Pathly copies the raw POSIX path. It does not URL-encode spaces as %20, and it does not add backslash escaping. For Python this is exactly what you want. For shell commands in Terminal, you'd still need to quote or escape the path yourself.

Summary: Which Approach for Which Situation

Situation Best approach
Quick analysis, file path won't change Copy absolute path from Finder, paste as string
Script you'll share or run on multiple machines pathlib.Path.home() with relative structure
Different files each Jupyter session Right-click in Finder → Copy Path → paste
Path has ~ tilde in it os.path.expanduser() or use Path.home()
Feeding file to an AI tool Copy as URL (file://) for apps that support it

The core insight: absolute paths always work. They're longer and less portable, but for the exploratory, single-machine work that constitutes most data science workflows, they're the pragmatic choice. Get the path from Finder fast, paste, run your code, move on.