A Python project can have its own Python version and installed packages. In PyCharm 2026.3 on the Linux desktop, you can set the project's Python interpreter to an existing virtual environment so that project runs use those packages.

PyCharm Run output showing Python and Colorama from the same virtual environment

A virtual environment has a Python executable under its own bin directory. Even when it uses the same Python version as the system installation, its executable gives the project access to packages installed in that environment.

A run configuration can specify its own interpreter. Running the current Python file from the editor gives you a way to check the project interpreter without relying on a configuration that may point elsewhere.

Steps to set a project's Python interpreter in PyCharm:

Start with a trusted local project open in PyCharm, Current File selected in the Run widget, and a Python file open that imports a package from the environment you want to use and produces output after the import. The pictures show forecast.py in ~/PycharmProjects/forecast and an environment named forecast-env under ~/Documents. Only run code from a project and environment you trust, since PyCharm executes the script and the code it imports.

If PyCharm shows the Air landing page or a Junie offer when you open the project, you can leave them alone and open your Python file from the Project tool window before step 1.

  1. Press Ctrl+Alt+S to open Settings. Forecast Python file open before choosing an interpreter
  2. Select Project Structure in the Settings sidebar. Project Structure near the top of the Settings sidebar
  3. Click the plus button beside Interpreter. Add Interpreter button next to the project Interpreter field
  4. Select Add Local Interpreter… from the menu. Add Local Interpreter menu item
  5. Choose Select existing under Environment in Add Python Interpreter. Select existing radio button in Add Python Interpreter
  6. Click the folder icon beside Python path. Folder icon in the Python path field
  7. Enter the full path to your virtual environment's bin/python in the chooser's path field, replacing the existing path. Path field in the Select Python Interpreter chooser

    The sample path is /home/reader/Documents/forecast-env/bin/python.

  8. Click OK in Select Python Interpreter. The virtual environment executable entered in the path field
  9. Press Enter in Add Python Interpreter to accept the selected executable. Selected Python path shown as a virtual environment
  10. Press Tab until the Auto-configure project workspace from pyproject.toml checkbox has keyboard focus once Interpreter shows your environment. Project Structure showing the selected interpreter and the checkbox to focus

    A blue outline around the checkbox shows keyboard focus.

  11. Press Enter to save the project interpreter. Keyboard focus on the checkbox before Enter saves Settings
  12. Click the green Run triangle beside Current File to run your open Python file. Run button for the active Python file
  13. Check that the first path in the Run tool window matches the bin/python executable you selected. Run command line beginning with the selected Python executable
  14. Check that Run shows the expected output from your script after the import. Colorama module path printed from the virtual environment

    The sample prints colorama.__file__, which ends in site-packages/colorama/__init__.py inside forecast-env. An import error means the run did not load the package.

Share this guide