venv guide

PyCharm virtual environment setup on Windows — venv & virtualenv guide

To create a virtual environment in PyCharm on Windows: File → New Project → select "New environment using venv". Or for an existing project: Settings → Python Interpreter → Add Interpreter → Virtualenv Environment → New.

Virtual environment options in PyCharm

venv
Built into Python 3. Lightweight, no extra install. Best for pure Python projects.
virtualenv
Third-party, more features than venv. Supports older Python versions.
Conda
From Anaconda. Handles non-Python dependencies. Best for data science.
pipenv
Combines pip and virtualenv. Good for web projects.

Create a virtual environment in PyCharm on Windows

  • 1

    New Project method (easiest)

    File → New Project. In the interpreter section, select "New environment using Virtualenv". Choose the base Python version. Click Create.

  • 2

    Existing project method

    File → Settings → Project → Python Interpreter → gear icon → Add Interpreter → Virtualenv Environment → New environment.

  • 3

    Or create from terminal

    PyCharm Terminal (Alt+F12)
    # Create venv in project folder:
    PS> python -m venv .venv
    # Activate:
    PS> .venv\Scripts\activate
    # Install packages:
    (.venv) PS> pip install requests pandas

venv questions

PyCharm venv not activating in terminal on Windows

PowerShell may block script execution. Fix: in PyCharm terminal run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser. Then activate with .venv\Scripts\activate. Or use cmd.exe instead: .venv\Scripts\activate.bat.

Using Conda instead?

Configure Anaconda environment in PyCharm.

Conda guide