Loading topic
venv or pip yet. This chapter explains the problem they solve. Later chapters cover the comman7 min readpython -m venv .venv and activate the result. It also assumes you know what import does and what sys.path is. Here you will look at what venv actually creates and how the interpreter uses it. That explains why activation is optional, why environments can't be5 min readpython -m venv .venv. It explains what activation does, how to run it on each platform, and how to work without it.5 min readvenv. It also assumes you can run commands in a terminal and know the difference between a Python script and a module. The commands below run inside an activated environment unless stated otherwise.6 min readpython -m pip install inside it. You should also know that a package has a name and a version number such as 2.32.3. Here you learn to say which versions of a package your project accepts.6 min readpython -m pip install. Every command below runs with the environment active, so python means the environment's interpreter. Once a few installs have accumulated, you need ways to answer6 min readpython -m pip install, and read version specifiers such as >=2.31,<3. If any of those is unfamiliar, review the earlier chapters first.6 min readpython -m pip install, and read a basic requirements.txt. It builds on those skills to answer one question. How do you get the same package versions on every machine without hard-coding every pin into the file that lists6 min readpython -m pip install, and read a basic pyproject.toml. Everything below runs inside an activated environment such as .venv.5 min readpython -m venv, install packages with python -m pip, and write a requirements.txt with pip freeze. You also need basic Git usage: git status, git add, and git commit. The chapter covers where an environment sho7 min readpython -m venv, and that you have installed packages with python -m pip. It covers the failures you are most likely to meet and how to tell them apart. Nearly all of them come down to one question: which interpreter is a6 min readpython -m pip, and read a requirements file. It covers where pip reads its settings, how those settings are ranked, and how to point pip at a package index other than PyPI.6 min readvenv and pip. It explains what each one adds and when to switch. It assumes you can create and activate a venv environment, install packages with python -m pip, and read a requirements.txt file. You should also know that an environment is a directory6 min read