Getting started with Python
This tutorial gets you up to speed with Python development in JetBrains Fleet. It covers the installation, project setup, and working with code.
Prerequisites
JetBrains Toolbox 1.22.10970 or later: the Download page.
Supported Python versions: 2.7 and from 3.6 up to the version 3.11.
Supported Python virtualenv: .venv/ or venv/ directories, projects that contain Pipfile or Poetry pyproject.toml files
Installing software
Download and install Python
Download the version of Python that corresponds to your operating system: https://www.python.org/downloads/
If you are on Windows, you can download Python from the Microsoft Store.
Download and install Fleet
Download and install JetBrains Toolbox.
In JetBrains Toolbox, click Install near the JetBrains Fleet icon.
Set up a workspace
Workspace is the directory where your project resides. It contains the project files and settings. You can open an existing project or start a new project by opening an empty directory.
Open a workspace
Press ⌘ O or select File | Open from the menu.
In the file browser, navigate to the folder containing your code and click Open.
The directory content appears in the Files panel. The workspace is added to list of the recently viewed workspaces.
Configure a Python interpreter
In Smart mode, which will be covered later, JetBrains Fleet automatically detects a virtual environment and configures a Python interpreter if your project workspace contains any of the following:
.venv/ or venv/ directories
Pipfile
Poetry pyproject.toml file
If none of the above is found, JetBrains Fleet will look for a Python executable in default locations.
Otherwise, you can configure a Python interpreter manually as described below.
Configure a Python interpreter for the workspace
Do one of the following:
Click the Python interpreter selector in the bottom-right corner of the JetBrains Fleet window:
Press ⌘ , and switch to the tab with the project settings. Then click the Python drop-down in the Toolchains | Python section:
Do one of the following:
Select one of the previously configured Python interpreters
Click Add, and then specify the path to a Python executable.
Enabling Smart Mode
You can use JetBrains Fleet as a smart text editor, rather than a full-fledged code editor. However, if you need code intelligence features, you can enable them by turning the Smart Mode on.
Enable smart mode
In the top-right corner of the window, click Smart Mode, then Enable.
After you click the Enable button, you may have to wait for some time, while the backend is being prepared.
Here's what you can do in Smart Mode. The below is not an exhaustive list of Smart Mode features, rather a couple of examples that'll help you to get the feel of how it works in Fleet.
Use quick-fixes and intention actions
Press ⌥ ⏎ to access actions that Fleet suggests in the current context.
Refactor code
Place the caret at a literal or select an expression, press ⌃ R, and enter the new name for the variable.
Navigate the codebase
Navigate to the declaration of a symbol with ⌘ B.
Use code interlines to navigate to usages and hierarchy members.
Skim over the errors with ⌘ E and ⌘ ⇧ E.
Running your code
With Smart Mode enabled and a configured Python interpreter, you can run your project. For that, you can use a gutter icon in the editor, or you can create a run configuration that will allow you to fine-tune the way your application should be run.
Run from the editor
Navigate to the entry point of your application and click the run icon in the gutter. Select Run `main`.
The results of script execution are shown in the bottom panel.
As mentioned before, another way to run a program is to use a run configuration. For more information, refer to Create and launch a run configuration.