Configure an interpreter using WSL | PyCharm (2024)

You can use Windows Subsystem for Linux (WSL) to work with a Python interpreter available in your Linux distribution.

Fulfill the preliminary steps

  1. Ensure that you have downloaded and installed Python on your computer.

    Installing Python on Windows from Microsoft Store

    If you are on Windows, you can download Python from the Microsoft Store and install it as a Python interpreter. Once the Python application is downloaded from the Microsoft Store, it becomes available in the list of the Python executables.

    Note that interpreters added from the Microsoft Store installations come with some limitations. Because of restrictions on Microsoft Store apps, Python scripts may not have full write access to shared locations such as TEMP and the registry.

  2. Click the Windows button in the lower-left corner of the screen and start typing System Information. To ensure that your system works well with WSL, upgrade your Windows to the latest available version.

  3. Install the Windows Subsystem for Linux and initialize your Linux distribution as described in the WSL Installation Guide.

  4. If your Linux distribution doesn't come with rsync, you need to install it:

Configure an interpreter via WSL

  1. Do one of the following:

    • Click the Python Interpreter selector and choose Add New Interpreter.

    • Press Ctrl+Alt+S to open Settings and go to Project: <project name> | Python Interpreter. Click the Add Interpreter link next to the list of the available interpreters.

    • Click the Python Interpreter selector and choose Interpreter Settings. Click the Add Interpreter link next to the list of the available interpreters.

  2. Select On WSL.

  3. Wait until PyCharm detects Linux on your machine and completes introspection. Click Next to proceed:

    Configure an interpreter using WSL | PyCharm (1)
  4. In the left-hand pane of the dialog, select the type of the WSL interpreter you want to create: Virtual Environment, Conda Environment, or System Interpreter.

    Configure an interpreter using WSL | PyCharm (2)

    For a system interpreter, just provide the path to the Python executable in the selected Linux distribution.

    For virtual and conda environments, you can provide a path to a Python executable of an existing environment in the selected Linux distribution or create a new environment based on the specified Python.

Once done, the new interpreter will be added to your project, and the default mnt mappings will be set.

PyCharm allows you to use custom Linux distributions run on WSL. PyCharm auto-detects such a distribution and adds it to the Linux Distribution list:

Create a WSL-based interpreter for a directory in \\wsl$

If you have any directory with some Python files in \\wsl$, you can open this directory in PyCharm. The IDE will create a project and suggest creating a WSL-based interpreter.

  1. Select File | Open from the main menu. Choose a directory in \\wsl$.

    Configure an interpreter using WSL | PyCharm (3)
  2. If PyCharm cannot discover any pre-configured WSL interpreter, you will see the banner prompting to discover Python in the Ubuntu installation:

    Configure an interpreter using WSL | PyCharm (4)

    Click Search for Python in Ubuntu to find a Python executable and create a WSL-based interpreter.

  3. Once the interpreter is created, PyCharm notifies you.

    Configure an interpreter using WSL | PyCharm (5)

Configure Terminal in WSL

  1. To run Terminal in WSL configuration, open project Settings/Preference (Ctrl+Alt+S) and go to Tools | Terminal.

  2. Specify the command in the Shell path field:

    • wsl.exe to use the default Linux distribution

    • wsl.exe -d <distribution name> to use a specific Linux distribution

    Click OK to save changes.

    Configure an interpreter using WSL | PyCharm (6)

Last modified: 07 March 2024

Configure an interpreter using WSL | PyCharm (2024)

FAQs

How to set Python interpreter in WSL? ›

Configure an interpreter via WSL

Do one of the following: Press Ctrl Alt 0S to open Settings and go to Project: workspace | Python Interpreter. Click the Add Interpreter link next to the list of the available interpreters. Click the Python Interpreter selector and choose Interpreter Settings.

How do I add an interpreter from WSL to PyCharm? ›

Configure an interpreter via WSL
  1. Do one of the following: ...
  2. Select On WSL.
  3. Wait until PyCharm detects Linux on your machine and completes introspection. ...
  4. In the left-hand pane of the dialog, select the type of the WSL interpreter you want to create: Virtual Environment, Conda Environment, or System Interpreter.

How to set Python interpreter in command line? ›

Windows: type "powershell" in the lower left, this opens the Windows command line terminal. In the terminal type the command "python3" ("python" on Windows, or sometimes "py"). This runs the interpreter program directly. On the Mac type ctrl-d to exit (on Windows ctrl-z).

How do I open interpreter settings? ›

All Settings
  1. Language Model Settings. Set your model , api_key , temperature , etc.
  2. Interpreter Settings. Change your system_message , set your interpreter to run offline , etc.
  3. Code Execution Settings. Modify the interpreter. computer , which handles code execution.

How do I change the Python interpreter in Linux? ›

Setting the default interpreter
  1. Go to File | New Projects Setup | Settings for New Projects (on Window and Linux) or File | New Projects Setup | Preferences for New Projects (on macOS).
  2. Select Python Interpreter settings. Then either choose an existing interpreter from the Python interpreter list of click.

How to set Python interpreter path in Linux? ›

If you are using the standard flavour of Linux, open up the bash shell and type the following phrase, export PATH=”$PATH:/usr/local/bin/python” and press Enter. If you have access to either sh or ksh shell, then open up the terminal and type the following, PATH=”$PATH:/usr/local/bin/python” and press Enter.

How do I add Python interpreter to Windows? ›

Configure a system interpreter

If you are on Windows, you can download Python from the Microsoft Store and install it as a Python interpreter. Once the Python application is downloaded from the Microsoft Store, it becomes available in the list of the Python executables.

What are the two ways to use Python interpreter? ›

There are two ways to use the python interpreter: interactive mode and script mode. (a) You can also save your commands in a text file, which by convention have the suffix “. py”, for example, program.py. (b) Create your list of commands inside any text editor, for example gedit.

Where is the Python interpreter path in cmd? ›

Method 1: Using Command Prompt (CMD)
  1. Step 1: Open Command Prompt. Press Win + R to open run window, type cmd, and press Enter.
  2. Step 2: Use the where Command. In the Command Prompt window, type the following command: where python. Press Enter, and the system will display the paths where Python is installed.
Aug 25, 2023

How to update Python interpreter in cmd? ›

Updating Python on Windows
  1. Visit the official Python website and Download Python for Windows.
  2. Run the installer, ensure to check the box that says 'Add Python to PATH'
  3. Follow the prompts to install Python.
  4. Once installed, verify the installation by opening Command Prompt and typing 'python –version'
Aug 22, 2023

How do I activate model interpreter? ›

To get started, just say “Hey Google, be my German translator” or “Hey Google, help me speak Spanish” and you'll see and hear the translated conversation on your phone.

What settings do interpreters work in? ›

Interpreters work in a variety of settings, including schools, hospitals, courtrooms, detention facilities, and conference centers; they also may work remotely. Some interpreters, such as liaison or escort interpreters, travel frequently.

What is interpreter mode in Python? ›

A python interpreter is a computer program that converts each high-level program statement into machine code. An interpreter translates the command that you write out into code that the computer can understand. However, to better understand this definition, we must explain what high-level and low-level languages are.

How to use Python from WSL? ›

  1. Set up your development environment. We recommend installing Python on WSL when building web applications. ...
  2. Install Windows Subsystem for Linux. ...
  3. Set up Visual Studio Code. ...
  4. Create a new project. ...
  5. Install Python, pip, and venv. ...
  6. Create a virtual environment. ...
  7. Open a WSL - Remote window. ...
  8. Install the Microsoft Python extension.
Nov 1, 2023

How do I add Python interpreter to Intellij WSL? ›

Navigate to File | Project Structure or press Ctrl Alt Shift 0S . , and choose Add Python SDK from the popup menu. In the left-hand pane of the Add Python Interpreter dialog, select WSL. Select the Linux distribution with the required Python interpreter.

How do I change the Python interpreter in Windows? ›

Move an interpreter
  1. Restore the Python interpreter to its original location.
  2. Uninstall the interpreter by using its installer, which clears the registry entries.
  3. Reinstall the interpreter at the new location.
  4. Restart Visual Studio, which should autodetect the new location in place of the old location.

How do I use Python interpreter in Windows? ›

Open a new terminal and type python or python3 . It should start the Python interpreter. The default is in c:\program files\python something these days. The exact location will depend on what OS you're using and how you installed it.

Top Articles
Latest Posts
Article information

Author: Carmelo Roob

Last Updated:

Views: 6284

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Carmelo Roob

Birthday: 1995-01-09

Address: Apt. 915 481 Sipes Cliff, New Gonzalobury, CO 80176

Phone: +6773780339780

Job: Sales Executive

Hobby: Gaming, Jogging, Rugby, Video gaming, Handball, Ice skating, Web surfing

Introduction: My name is Carmelo Roob, I am a modern, handsome, delightful, comfortable, attractive, vast, good person who loves writing and wants to share my knowledge and understanding with you.