Introduction to Python Getting Started with Python and the ...

[Pages:6]Introduction to Python

Getting Started with Python and the PyCharm Editor/IDE

Goals for Getting Started:

? Install the Python interpreter for running programs ? Install the PyCharm text editor/IDE for writing programs ? Download and install the custom PyCharm settings file for this course

Before our first class, you should complete these instructions, as well as those in the "Writing, Running and Debugging Programs" document.

Sometimes it seems more efficient to "skim" long instructions and skip ahead on your own; please don't do that here. Instead, read and patiently follow these instructions to the letter, and let me know if you encounter any problems or if you have questions.

Keep in mind that any divergence from these instructions can create problems now, or later in the course. One of the first lessons that I can offer to you is the necessity for attention to detail in this environment.

(If you already know how to write and run Python programs, you may not need the instructions that pertain to the PyCharm text editor/IDE. However, you may find it to be a helpful tool. PyCharm is well regarded in the industry. I will be using PyCharm for most class demonstrations, including the use of its valuable debugger.)

If you decide to use another IDE (such as VSCode) for this class, you must inform me as soon as possible. In addition, you'll be "on your own" regarding using the program. I do not recommend using an IDE you are not already familiar with.

These instructions should work on any standard computer (Windows, Mac or Linux). If you are hoping to do your classwork on a Chromebook, iPad or other nonstandard computer, this may be possible, but I do not have any specific instructions. Let me know if this is the case for you.

Writing and running programs

There are two components needed for writing and running programs:

1. the python interpreter (a program for reading your Python statements and converting them into machine instructions)

2. a text editor or IDE (Integrated Development Environment, basically a text editor that understands that you are writing code, and can send the code to the interpreter for execution).

Installing the Python Interpreter from Anaconda

I recommend Anaconda Python: ? a popular distribution of Python ? includes the Python interpreter ? adds useful tools for learning and collaboration, such as Jupyter notebook ? adds many useful modules for finance, web and scientific computing ? requires 3-4GB of space on your computer's disk (you should have at least 5-8GB available on disk before installing). If you do not have this much disk space available, you may install a distribution from ; please see below

1. Check the amount of available disk space on your computer.

a. On Mac:

i. open a Finder (file listing) window and display a folder of files (for example, your Desktop -- but not "All My Files")

ii. Look at the bottom of the window - you should see XX GB available iii. If you don't see this text at the bottom of your Finder window, go to View > Show

Status Bar iv. Another way: click on the Apple icon at the extreme top left, then go to About This

Mac > Storage ? your hard drive and available space should appear at the top

b. On Windows:

i. in the search box, do a search for This PC, or look for it on the Desktop ii. scroll down to the disk drives (with horizontal bars illustrating space used) iii. look for XX GB free message for your main hard drive

If you have at least 5GB of space available on your disk, follow Step 2 below (your disk should not have less than 2GB free after installation). If you don't have enough disk space, you can install the much more lightweight Standard Distribution of Python; please see the Install Python from instructions, then return to Installing PyCharm, below.)

2. Install Python from Anaconda. In this step, Python 3 will be installed onto your Mac or Windows computer. (Again if you do not have 5GB free on your computer, you can install the Standard Distribution of Python -- see the separate document Install Python from . When done, return to Installing PyCharm, below.)

* Please note that you never need to uninstall any version of Python! Multiple versions can be, and often are, installed on the same system (I currently have four versions installed on my system). If you find that the wrong version of Python is run when you try to use it, we will simply change the 'default' version for your system.

a. Visit

b. Find and click the Free Download link at the top right

c. Click the Download button (which should indicate your OS (Mac or Windows). For Mac, click the small arrow on the right side of the button and choose the correct Mac type

d. The installer will begin to download, usually to your Downloads folder.

e. When complete, find and double-click the installer.

f. Accept all of the prompts and defaults.

g. By default, Anaconda will be installed in a directory located off of your home directory. If you see a warning sign and "You cannot install Anaconda3 in this location", you must install from your home directory.

h. PLEASE NOTE if the Anaconda installer asks for your permission to make changes (requesting a password), please stop installation and start again, making sure to install for "Just Me" or "Me Only". The installer should note that Anaconda will be installed in your home directory.

If it appears that Anaconda is being installed into a directory other than your home directory: when you see the button change install location, please click the button and select your home directory, even if you see an error message similar to "Anaconda cannot install in this location". After selecting your home directory, you should be able to install Anaconda without giving a password.

Note that the installer may invite you to download and install PyCharm; we will do so ourselves in the next section.

i. Installation may take several minutes. When done, the installer will tell you installation is complete.

Installing the PyCharm Editor/IDE

1. Download and Install PyCharm.

a. Special Notes on Text Editor / IDEs:

? if you have PyCharm already installed, you can skip this section on installing, but we will also make sure that PyCharm is using Anaconda as its Python version

? if you prefer to use another IDE or text editor (such as VSCode, IDLE, Sublime, Eclipse, etc.) you may do so, but I strongly recommend that you proceed only if you're familiar with using this tool to perform the following: writing and running Python programs; inputting text at the keyboard with the input() function. If you're not sure about any of these items and still want to use a different IDE, please contact me.

? please do not expect to use Jupyter notebook as your main text editor / IDE. We may make some use of Jupyter for in-class exercises and tests only. Jupyter is not appropriate for project work!

b. Visit the download page at

c. Immediately beneath Download PyCharm, make sure that your operating system (Windows, macOS or Linux) is selected (it will be highlighted with an underline).

d. Make sure to choose Community Edition on the right side (do not install Professional Edition as it will require a purchase after a trial, and includes features that we do not need). For Mac, make sure the correct .dmg is selected ? if your Mac has an M-series chip, you should select Apple silicon; those with non M-series chips should select Intel. You do not need to provide your email address or sign up with the website, although you may be invited to do so.

e. Download will begin. Keep in mind you do not need to provide your email address or sign up with the website.

f. Once downloaded, doubleclick the downloaded file:

i. On Mac:

a. a window will appear suggesting that you drag the PyCharm icon ("PC") to your Applications Folder -- you can do so right in that window (you may need to enter a password, or confirm that this program is safe to run -- it is!).

b. once the program is in Applications, you can also create a shortcut to the application if you wish, by dragging it from Applications to your Dock (the horizontal bar at the bottom of your screen with icons that launch programs). You can also create a Desktop shortcut by dragging the icon from Applications and holding down the Cmd+Option keys (so that a swoopy arrow indicating a shortcut is displayed) before releasing on the Desktop. (If you don't see a swoopy arrow, the application itself will be moved to the Desktop, which you do not want - it belongs in the Applications folder.)

ii. On Windows:

a. follow the installer steps and accept all defaults.

b. During the install process you can choose to have a Desktop Shortcut placed on your Desktop. (You will also be able to launch PyCharm using the search or Start > Run... box.) You can also choose to associate .py with PyCharm, but I do not recommend this.

c. Continue to click Next until installation is complete. You may also choose to launch PyCharm for the first time here.

2. Launch PyCharm and respond to initial settings questions. For Mac, find the PyCharm PC icon in Applications and double-click it, or if you placed an icon in the Dock at the bottom of your screen, you can simply click that. For Windows, use the icon you placed on your Desktop or go to the search box and type PyCharm; you should see your program listed as JetBrains PyCharm; click it.

PyCharm may ask a series of questions, for example if you would like to import settings (please do not import any settings), and share usage data with JetBrains to help them improve the product (this is your choice). PyCharm may also ask you to select a Keymap (choose the one appropriate for your platform), a Light or Dark color scheme (recommended choices: "Darcula" or "High Contrast", but you may also select a light color scheme), a launcher script (skip this), and download plugins (skip this). These questions may or may not appear during this step.

Finally, you can click to launch PyCharm.

3. Check out the PyCharm Welcome Screen. This medium-sized box shows the PyCharm PC icon and "Welcome to PyCharm" at the top. This will be the starting point when we create new projects in PyCharm.

1. Projects on the left is where we can manage projects that we work with. 2. Customize allows us to set color theme and font sizes. However, we will set these as

part of the next step.

4. Custom configure PyCharm. In this step, we will configure PyCharm with a custom settings file that I have provided. These settings specify a high-contrast color scheme, large font and suppresses many of the warnings, popups and completion alerts which PyCharm customarily displays. Unless you have a specific objection to any of this, please complete the below steps for configuring PyCharm.

a. Download the custom settings file for your computer from my website (but don't open the file).



Click on the link or copy the above URL to your browser and it will start the download (a very small file) which usually will be downloaded to your Downloads directory. (Do not unzip this folder.)

If your browser or system asks whether you want to open the file, please choose to Download or Save the file. Please don't open the file -- if you open it and save it, it may become corrupted -- if you have opened it, simply download it again.

If you click on the link and nothing seems to happen, and if you are on Chrome, please right-click the link and choose Save Link As, and then confirm to Chrome that you want to keep the file. (The security warning may appear for any .zip files, but this .zip file is clean.)

b. Import the custom PyCharm Settings. As mentioned, importing these settings will enlarge your code font and remove a lot of distracting alerts and warnings.

i. On the left click Customize, then Import Settings

ii. Find the .zip file you saved in the 'Download the custom settings file' step

Windows: to help locate the settings file you saved, PyCharm shows you a file system tree -- the Downloads folder will usually be located at C:\Users\[yourhomedir]\Downloads. Or, clicking the little house (home directory) icon you should see Downloads listed from there.

iii. Click OK or Open

iv. All boxes should be selected -- click OK

v. PyCharm will indicate that it needs to restart -- click Import and Restart

vi. After PyCharm restarts, it should present the same Welcome dialog. If you had chosen a light color scheme, you'll see that it has become dark again -- see below if you prefer a light color scheme.

vii. From now on, PyCharm remembers the settings -- you will not need this again.

viii. Choosing a color scheme after loading settings: the high contrast color scheme is designed to be easy on the eyes, but some prefer light colors. I suggest you complete these instructions before considering a light color scheme ? but if you prefer a light color scheme you can reverse the colors as described below.

5. Set Font Size and Color Scheme. Please keep your font large. Don't strain your eyes!

a. On the left, click Customize.

b. From here you can select a different color scheme (the settings file has set to "High contrast", which I recommend) and an IDE font (I recommend 13).

If you've made it this far, congratulations! You've taken your first major step successfully!

Note: all of the above instructions describe initial setup and usually have to be taken only once. Please proceed to "Writing, Running and Debugging Programs".

If you see any errors, anomalies, or if anything seems confusing in these instructions, please let me know as soon as possible. You'll be helping others if you do (or allowing others to be confused if you don't!).

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download