Installing PyCharm for CS51A

For this class, we'll be using Python (version 3.10) and the PyCharm IDE. These are both installed on the machines in the CS labs (Edmunds 105, 219, 227 and 229), which you have access to. If you want to use your own computer, you'll need to install PyCharm and a recent version of the Python programming language. To obtain PyCharm, you can either apply for the JetBrains student pack to get the full commercial version of PyCharm, or use the free community edition. Go ahead and start downloading that while we set up Python.

To install Python, start at the the official Python website. Look for the appropriate package for your operating system (macOS or Windows), processor architecture (32 or 64 bit, probably 64), and installation mode (probably choose the executable installer). Macs have all been 64-bit for quite some time, but if you want to check whether your Windows machine is 64-bit you can follow these instructions.

On Windows, you may need to follow an extra step so your computer knows where Python is installed:

Now that we have Python installed and PyCharm has downloaded, you can install PyCharm. Go ahead and run it (choose "Do not import settings" if prompted), pick the color scheme you like, create a launcher script if you want to, then keep clicking through the default choices until you get to the welcome screen. If you have any trouble, please make a post on Piazza—other folks might be having the same issue!

At the welcome screen, click the "Create New Project" button, give your project a name ("Test Project" maybe), then unfold the "Project Interpreter" menu. Using a virtual environment is fine for now; the important step here is to look for the "Base interpreter" option which determines which version of Python will be used for your program. We want to pick the Python we just installed, 3.10, so if that's available in the dropdown then use it; otherwise, click the "..." and navigate to wherever you installed Python and find a file with a name like python38.

To test out your setup, go to PyCharm's Tools menu and select Python Console.... Look for the three green rightwards arrows (greater-than signs), click in the console window just to the right of those arrows, then type verbatim print("hello, world!") and hit return. If the friendly prompt replies with a greeting, you're good to go!

We can also create and edit files from PyCharm. Go to the File menu and choose New... then Python File. Type in a name (like "test") and hit return, and PyCharm will make a Python file for you (ending in .py) and open it up. Paste that same code from before (print("hello, world!")) into this file. Next, right click (or control-click) anywhere inside the text editor and pick "Run File in Python Console". After you do this once, you could also press the green triangle button in the top right corner, or hold shift and press the F10 key on your keyboard.

Finally, it's worth taking some time to make PyCharm your own. You can customize it using the File menu's Settings item, and it's okay to poke around and mess with stuff—it's impossible to break things too badly. You might want to start with the font size, for example.

One last tip before you go: At any time you can press the control (or possibly command, the "apple key", or alt/option, depending on your key bindings), shift, and "A" keys at the same time to bring up an action palette which is great for doing all kinds of things: running code, interacting with the Python console, creating new files, and more. You could also tap the shift key twice to bring it up. This kind of feature is in lots of programming tools now, so it's worth playing around with it while you learn PyCharm.