for WSL

Instructions for installing PyCharm to work with the Windows Subsystem for Linux

This lab is for those who are on Windows and have set up the Windows Subsystem for Linux (WSL) following Option 1 from the Installing a *nix operating system lab.

Installation

  1. You must request a free PyCharm Professional license. Sign up using your @uncw.edu email address.
  2. Download and install PyCharm for Windows. You must have Pycharm Professional, not the Community edition.
  3. Complete the install process. I recommend the options below, but they are not required:
    Pycharm installation options on windows

Setup

  1. Run PyCharm after installation is complete.
  2. You should see a prompt to activate the license. Select “Activate License” then “Log In to JetBrains Account”.
    PyCharm license activation prompt
    Pycharm activation options
  3. Complete the login process using the Jetbrains website.
  4. You should now see a “Welcome to PyCharm” screen. Select “WSL” in the left pane, then click “New Project” in the main pane.
    Selecting WSL from the PyCharm home page
  5. You WSL instance you created should already be selected. Click “Next”.
    Choosing a WSL instance.
  6. PyCharm will process for a minute then present a “Choose IDE and Project” screen. Leave the “IDE Version” as-is. Click the ... next to the “Project directory” selector.
    IDE and Project configuration options.
  7. We are now going to create a directory in Ubuntu to keep all your class projects. We will also create a new test subdirectory in that directory.
    1. In the pop-up, expand the directories to select \\wsl.localhost\Ubuntu\home\<your_username>. Left click to select the directory.
    2. Then click the “New Directory” button at the top.
    3. Then enter seng-201 in the pop-up name box.
      Creating the 201 folder
    4. Now select the seng-201 folder and click the “New Folder” button again. Enter pycharm-test in the box.
      Creating a test project.
    5. Finally, select the pycharm-test folder and click “OK”.
  8. You will be back on the “Select IDE and Project” page. It should look like below. Click the blue “Download IDE and Connect” button.
    Accept project settings.
  9. PyCharm will take several minutes to download and configure necessary software to talk to your Ubuntu instance. After it completes, you will be shown a user agreement. Accept it.
    Download progress.
    License agreement.
  10. Finally, you should see the PyCharm IDE editor window. Click the Play button at the top to see the Python program run. You are done with the setup.
    PyCharm running on WSL

You may see some Windows Firewall pop-ups. It is okay to allow them.

Configure the Ubuntu CLI

Finally, we are going to make it so you can open PyCharm from the Ubuntu CLI. This will be very convenient later.

  1. First, close PyCharm.
  2. Open an Ubuntu Terminal as described in the previous lab.
  3. Run the following command, which will create an alias to run PyCharm from the command line:
bash

printf "pycharm() { \"/mnt/c/Program Files/JetBrains/PyCharm 2024.3.1.1/bin/pycharm64.exe\" \"\$@\" > /dev/null 2>&1 & }\n" >> ~/.bashrc && source ~/.bashrc

Test drive

Let’s open PyCharm from the Ubuntu CLI and do somet light editing.

  1. Run the following commands from the Ubuntu terminal:

    bash
    
    cd       # make sure in your home directory
    cd seng-201
    cd pycharm-test  # change to test directory
    pycharm .   # launch PyCharm in the current directory
    

  2. PyCharm should open after a moment. You may see a prompt to “Trust the directory…”. Do that. You may need to click on the Explorer icon in PyCharm to see your files:

  3. Go back to your Ubuntu terminal and make sure you are in the pycharm-test directory.

  4. Type the command touch hello.py to create an empty Python file.

  5. Go back to PyCharm. You should see the file hello.py in the directory here. Click on it and it will open an empty editor pane.

  6. In the code editor, type print("Hello World").

  7. Go back to the Ubuntu Terminal and type cat hello.py. You should see the code.

Next

So you now have PyCharm successfully editing files and interacting with directories inside Ubuntu.

You are now ready to code! Move on to the PyCharm basics lab.

Last modified January 23, 2025.