Python for JS Devs · Fundamentals

From npm to uv

Set up a real Python project and run your first Python — using the tooling map you already have in your head.

Lesson 01 Time ~12 min Win A working uv project you can run Prereq None

You already know how a JS project comes together: node runs code, npm manages dependencies, nvm manages runtime versions, package.json declares everything, and a lockfile pins it. Python has historically split these across a pile of tools (python, pip, venv, pyenv, pipx…). uv collapses all of that into one fast tool — think of it as npm + nvm + npx in a single binary.

Your mental map The whole point of this lesson: you don't need new concepts, just new names for concepts you own. Here's the translation.

The tooling translation

JavaScript world Python + uv world What it does
node app.jsuv run app.pyRun a file (in the project env)
npm inituv initScaffold a new project
npm install xuv add xAdd a dependency
npm installuv syncInstall everything from the lockfile
npx cowsayuvx cowsayRun a tool without installing it
nvm use 20uv python pin 3.13Pick the runtime version
package.jsonpyproject.tomlProject + dependency manifest
package-lock.jsonuv.lockExact pinned versions
The one genuinely new idea A virtual environment (.venv/) is Python's answer to node_modules/: an isolated per-project folder holding that project's dependencies and its own Python interpreter. The twist vs. Node: in Node the isolation is automatic; in Python you historically had to "activate" the venv. With uv you never activate anything — uv run uses the project's .venv automatically, exactly like npm scripts see node_modules.

Step 1 — Install uv

One command, no Python required first (uv can install Python for you):

# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

Verify it's there:

uv --version

Step 2 — Create a project

uv init hello-python
cd hello-python
uv python pin 3.13   # write .python-version, like an .nvmrc

Look at what uv scaffolded — every file has a JS analogue you already know:

hello-python/
├── pyproject.toml      # package.json
├── .python-version     # .nvmrc
├── README.md
└── main.py             # your entry file

Step 3 — Run your first Python

Open main.py and replace it with this. Notice how little is ceremony:

JavaScript
function greet(name) {
  return `Hi, ${name}!`;
}

const user = "Karthik";
console.log(greet(user));
Python
def greet(name):
    return f"Hi, {name}!"


user = "Karthik"
print(greet(user))

Four differences to notice right now (we'll go deep on these next lesson):

Now run it — no activation, no build step:

uv run main.py
# → Hi, Karthik!

Step 4 — The REPL (your instant playground)

Just like typing node with no args drops you into a JS shell, uv gives you a Python REPL wired to your project:

uv run python
>>> greet = lambda n: f"Hi, {n}!"
>>> greet("world")
'Hi, world!'
>>> exit()
Habit worth forming The REPL is the fastest feedback loop in Python. When you're unsure "what does this return?", don't guess — paste it into uv run python and look. You'll use this constantly.

🎯 Your win — do this now

Run the four commands, get Hi, Karthik! to print via uv run main.py, then open the REPL and add a second function shout(msg) that returns the message uppercased (hint: try msg.upper() in the REPL). If it prints, you've set up and run a real Python project. That's the whole foundation.

Check yourself

Retrieval practice — answer from memory before clicking. Getting it slightly wrong is how it sticks.

Q1. Which uv command adds a dependency to your project?
uv add mirrors npm install <pkg>: it installs the package, updates pyproject.toml, and refreshes uv.lock.
Q2. In Python, what actually defines a block of code?
Indentation is syntax, not style. Inconsistent indentation is a real error, not a lint warning.
Q3. The .venv/ folder is most like which JS thing?
A venv is per-project isolated dependencies (plus its own interpreter) — the node_modules role. With uv you never manually "activate" it.
Primary source — read next uv — Getting Started (Astral official docs). Skim "First steps" and "Projects." It's short and authoritative; everything above comes from here. See also the uv cheat sheet in this course for a one-glance reference.
💬 I'm your teacher — ask me anything. Stuck on install, confused why there's no activate step, or want to know how uv differs from poetry/pip? Just ask in the chat.