Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › Developer Tools

How to Install Python and Set Up a Virtual Environment

By Freedom251 Team · · 12 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install a supported Python 3 interpreter, verify which command starts it, then create a project-local environment with python -m venv .venv. Activate that environment before installing packages, use python -m pip so pip belongs to the selected interpreter, and recreate the environment from a requirements file when necessary.

What you are setting up

Python is the interpreter that runs your programs. A virtual environment is a separate directory containing an environment-specific Python setup and package location. It is created from an existing base Python installation; it does not install Python by itself.

As an Amazon Associate I earn from qualifying purchases.

The Python documentation describes venv as creating lightweight virtual environments, each with its own independent set of Python packages in its own “site” directories. In practical terms, a package installed while one environment is active goes into that environment by default instead of being mixed with your base installation or another project.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The standard-library method works for ordinary project work:

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
python -m venv .venv

.venv is a conventional project-local name, not a required one. You can use another directory name, but keeping one predictable name makes documentation, editor settings and team instructions easier to follow.

Before you install anything

Have a supported Python 3 interpreter source

Choose either the current installer supplied through Python’s official downloads or the package source maintained for your operating system. The exact installer screens, package names and available Python versions vary by platform and distribution, so follow the current instructions for your system rather than copying a command intended for a different Linux distribution or an outdated release.

The PyPA packaging guide cited for this workflow applies to supported Python versions currently listed as 3.8 and newer. That range changes as Python releases reach and leave support; use the current support information when selecting a release. The venv module itself was added in Python 3.3 and later Python 3 installations normally include it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Know which terminal you are using

Activation is shell-specific. The commands in this guide distinguish Unix-like shells, Windows PowerShell and Windows Command Prompt. Fish and csh use their own activation scripts. If you work inside an IDE, its integrated terminal still follows the shell selected for that terminal.

Prepare a project directory

Use a directory that will contain your source code and dependency file. The environment should live inside that project directory, but it should not be committed to version control. A virtual environment contains machine-specific paths and generated files; it is normally disposable and reproducible from dependency information.

Install Python for your platform

Windows

Install a current supported Python 3 release using the official Windows distribution or an appropriate Windows-managed installation source. After installation, Windows systems commonly provide the py launcher; some installations also expose python. Do not assume both commands refer to the same interpreter. You will verify the command that your machine actually uses in the next section.

When an installer offers choices affecting command-line access, follow the current official Windows guidance. If a command is not recognized after installation, reopen the terminal so it receives updated environment settings, then check the available launcher commands.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

macOS

Use the current official Python distribution or a package source appropriate for your Mac. macOS commonly uses the versioned command python3 rather than python. The installer and shell configuration determine which command is available, so verify it instead of relying on an assumption about the operating system.

Linux and other Unix-like systems

Use your distribution’s current package documentation or the official Python distribution instructions. Linux package names and commands differ among distributions and may differ between system images, containers and managed workstations. There is no single Linux installation command that is correct everywhere. Once Python is installed, the interpreter is commonly invoked as python3, but confirm that on your system.

Installation-route comparison

Route What it means What you must verify
Official Python distribution You install the current interpreter published for your platform. Which executable name the installer provides and whether the shell can find it.
Operating-system package source Your operating system manages the Python package and its updates. That the package is a supported Python 3 interpreter and that the distribution includes the components needed for venv.

Whichever route you choose, use one interpreter consistently for a project. Mixing a system Python, a separately installed Python and an IDE-selected Python is a common cause of packages appearing to be installed but not importable.

Verify the interpreter before creating an environment

Open a new terminal and ask the command you intend to use for its version. Run the command that matches your system:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python --version
python3 --version
py --version

You do not need all three commands to work. The useful result is a supported Python 3 version from the interpreter you plan to use. If one command is missing, try the platform-appropriate alternative rather than installing a second interpreter immediately.

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

On Unix-like systems, you can see which executable a shell will run with:

command -v python
command -v python3

On Windows Command Prompt, the corresponding check is:

where python
where py

Check pip through the same interpreter:

python -m pip --version

Replace python with python3 or py if that is the command that starts your chosen interpreter. The python -m pip form is deliberate: it asks that exact Python interpreter to run its associated pip, avoiding a mismatch with a pip executable earlier on your PATH.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If none of the commands works, Python is not available to that terminal yet. Recheck the installation instructions for your operating system, reopen the terminal after installation, and verify the command again. Creating a virtual environment cannot correct a missing base interpreter.

Create a virtual environment in your project

  1. Create or enter the project directory using your normal file-management method. For example, once the directory exists, change into it in the terminal:

    cd path/to/your-project

    Use the actual path for your project; the example is intentionally platform-neutral.

  2. Run venv through the interpreter you verified:

    python -m venv .venv

    On a system where python3 is the verified command, run:

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    python3 -m venv .venv

    On Windows where the py launcher is the intended interpreter, run:

    py -m venv .venv
  3. Wait for the command to finish. It creates the .venv directory and the files needed to activate that environment. The command requires an existing Python installation and does not replace or modify the system interpreter with a project-specific Python.

Use the same interpreter family for creation and later work. For example, if you create the environment with python3, use its activation script and then the environment’s python command for package operations.

Activate the environment

Activation changes the current shell so that python, pip and related commands resolve to the project environment first. It is a convenience for selecting the environment; the environment’s files remain in .venv.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Unix-like systems: bash and compatible shells

source .venv/bin/activate

The Python tutorial’s Unix/macOS example is for bash. Other shells use different scripts. For example, csh and fish have their own activation files; use the script supplied in .venv/bin for the shell you actually run rather than applying the bash command unchanged.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Windows PowerShell

.venvScriptsActivate.ps1

PowerShell can block local scripts under its execution-policy settings. If activation is refused, the Python venv documentation gives this current-user option:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

This changes the policy for your user account, not the entire computer. It permits locally created scripts while requiring signatures for scripts downloaded from the internet. Review your organization’s policy before changing it; on a managed device, an administrator may control the setting.

Windows Command Prompt

.venvScriptsactivate.bat

Use the command that matches the terminal in which you will run your project. Activating in one terminal does not activate the environment in a separate terminal window.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recognize activation

Most shells add the environment name, usually (.venv), to the prompt. Treat that marker as a hint, not as proof. Verify the interpreter after activation so you know the shell is using the intended files.

Confirm that the environment is active

Run:

python --version
python -m pip --version

Then inspect the executable path. On Unix-like systems, run:

command -v python

On Windows Command Prompt, run:

where python

The reported path should point inside your project’s .venv directory. If it points to a system location, activate the environment again in that same terminal or use the environment’s interpreter directly. This check is especially useful when an editor opens a different terminal profile than the one you used to create the environment.

Install project packages with pip

With the environment active, install a package through its interpreter. The example below uses requests only as a command illustration; your project may need a completely different package:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m pip install requests

Because the environment is active and pip is invoked through python, the package is installed into that environment’s package area by default. It does not become a dependency of every Python project on the machine.

Use the same pattern for upgrades or additional packages:

python -m pip install package-name
python -m pip install --upgrade package-name

Replace package-name with the actual package identifier. Do not copy a package name from an unrelated tutorial merely to test the command; install only dependencies your project requires.

Record dependencies in requirements.txt

A requirements file is a plain-text list of packages that another environment can install. Create requirements.txt in the project directory and record the dependencies your application needs, one package requirement per line. Then install the recorded set with:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
python -m pip install -r requirements.txt

This gives a new environment a repeatable starting point. Keep the file with your project source, while keeping .venv itself out of version control.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

If you need a snapshot of what is currently installed, pip can write its package list to a file:

python -m pip freeze > requirements.txt

Review that file before sharing it. A freeze captures the environment’s installed packages, which can include tools or transitive dependencies that your project does not intentionally treat as direct requirements. Whether you maintain a hand-written dependency list or a generated snapshot, use the resulting file when recreating the environment.

Use the environment during normal development

A simple daily workflow is:

  1. Open a terminal in the project directory.

  2. Activate .venv with the script for that terminal’s shell.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Run your program, test runner and package commands through the active environment.

  4. Install only project dependencies into that environment and update the requirements file when the dependency set changes.

  5. Deactivate the environment when you finish or before switching to another project.

Many editors can be configured to use a project interpreter located at .venv. The exact menu labels differ by editor and operating system. Regardless of the editor, confirm its selected interpreter path points to this project’s environment; an editor can otherwise run a different Python even when your terminal is correctly activated.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Deactivate, recreate and remove an environment

Deactivate it

When you are done in the current shell, run:

deactivate

This restores the shell’s previous command resolution. It does not delete files or uninstall packages.

Recreate it after a breakage or move

Virtual environments are intended to be disposable. If an environment becomes inconsistent, or if a project is copied to another computer, remove the old .venv directory using your operating system’s normal file-removal command, create a new one with the same interpreter command, activate it and reinstall from requirements.txt:

python -m venv .venv
python -m pip install -r requirements.txt

Run those commands from the project directory, and activate the new environment before the installation step when your shell workflow requires activation. Do not move or copy a virtual-environment directory between machines as though it were portable application data; paths and interpreter locations can be tied to the original installation.

Exclude it from version control

Add .venv/ to the project’s ignore file for your version-control system. Commit the source code and dependency information, not the generated environment directory. Anyone checking out the project can then create a fresh environment with the documented interpreter and requirements file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

venv and virtualenv: which should you use?

Consideration venv virtualenv
Availability Included in the Python standard library for Python 3.3 and later. A separately installed tool.
Basic project isolation Creates the lightweight environment needed for ordinary application projects. Also creates isolated environments and may offer features beyond the standard-library workflow.
Extra installation None beyond the Python installation and its available venv component. Requires installing and maintaining the tool itself.
Best default for this task Use first when the project only needs a conventional Python 3 environment. Choose only when your project or organization has a documented compatibility or feature requirement.

For the title task, adding another environment tool is unnecessary. Start with venv; adopt virtualenv when a stated Python-version compatibility need or workflow feature justifies the additional dependency.

Troubleshoot the common failure points

“python” or “python3” is not recognized

  • Confirm that Python was actually installed rather than only downloaded.
  • Open a new terminal after installation so updated command settings are loaded.
  • Try the platform’s alternate command: py is commonly available on Windows, while python3 is common on Unix-like systems.
  • Run the version command for the interpreter you intend to use, then use that same command to create the environment.

If no interpreter command works, do not proceed to venv; fix the base installation or consult the current platform instructions first.

The environment was created, but packages appear to be missing

Check both the active interpreter and pip:

python --version
python -m pip --version
command -v python

Use where python instead of command -v python in Windows Command Prompt. If the path is outside .venv, activate the environment in the current terminal. If it is inside .venv but the package is still absent, install it with python -m pip install package-name while that environment is active.

PowerShell refuses the activation script

PowerShell’s execution policy may block the script. The user-scoped option documented for this workflow is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Use an administrator or organizationally approved approach if policy prevents this change. You can also use Windows Command Prompt and its activate.bat script instead of changing PowerShell settings.

python -m venv .venv fails because venv is unavailable

The command depends on the Python build and operating-system package providing the venv component. Check the installation documentation for that exact distribution and install the corresponding component or use the official Python distribution. Do not substitute a random Linux command from another distribution.

Activation works in one shell but not another

Each shell has its own activation script and process state. Activate again in the new shell using the matching path: .venv/bin/activate for bash-compatible Unix shells, .venvScriptsActivate.ps1 for PowerShell or .venvScriptsactivate.bat for Command Prompt.

An IDE runs the wrong Python

Compare the IDE’s selected interpreter with the path reported by the activated terminal. Select the interpreter inside this project’s .venv directory, then rerun the program or tests. Terminal activation does not automatically change an already configured IDE interpreter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Practices that keep projects reproducible

  • Create one environment per project. Separate environments prevent unrelated dependency changes from colliding.
  • Use the environment’s interpreter for pip. Prefer python -m pip over a bare pip command when more than one Python installation exists.
  • Keep dependency information with the source. A requirements file lets you rebuild a clean environment instead of preserving a fragile directory.
  • Ignore .venv in version control. The generated directory is disposable; the project’s dependency description is the durable artifact.
  • Check paths when something behaves unexpectedly. Version output and the executable path reveal which interpreter is actually running.
  • Follow current platform guidance. Installer availability, supported Python versions and operating-system package names change over time.

There is no special hardware, boxed software or physical installation media required for this workflow. You need a supported Python interpreter, a terminal and the standard-library venv module supplied by the chosen Python installation.

The complete command sequence

Once Python is installed and verified, the essential project setup is:

cd path/to/your-project
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt

The activation line in that block is for bash-compatible Unix shells. On Windows, replace it with the PowerShell or Command Prompt command shown earlier. If you do not yet have a requirements file, install the project’s packages individually with python -m pip install package-name, then record the resulting dependency set for future recreations.

The key decisions are consistent across platforms: install Python first, use the command that identifies the intended interpreter, create .venv inside the project, activate it with the correct shell script, and run pip through that environment’s Python.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Developer ToolsPiPProgramming setupPythonvenvvirtual environment

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.