Getting Started with Python
There are a couple options for setting up your environment with Python. You can install all your tools piece-by-piece, or you can install an all-in-one virtual environment that contains everything you need.
Piece-by-Piece
With this method, you will need to install Python, a text editor, and Jupyter separately.
- Download and install Python from python.org. Make sure you include “pip” in Optional Features and “Add Python to environment variables” in Advanced Options.
- Open a terminal (such as Windows CMD, Git Bash, or iTerm) and check the installation with this command:
python --version
If you see the python version print to the console then you are ready for the next step. If not, you may need to set your PATH variable on Windows to use the Python executable.
- In the terminal, install JupyterLab with this command:
pip install jupyterlab
If the command line does not recognize
pip
, then you can try:python -m pip install jupyterlab
If pip in not installed, then the command above will also fail. In that case, check here for instructions on installing pip.
- After installation completes, launch JuptyerLab with the command:
jupyter-lab
Alternatively, the Jupyter Notebook app is more lightweight and may be easier for beginners. You can run it with this command:
jupyter notebook
- Download and install a text editor if you do not have one already. Visual Studio Code is a popular free editor with extensions for Python and Jupyter.
All-in-One
With this method, you can simply install Anaconda. Anaconda is a virtual environment application with an intuitive interface for managing your tools and software configurations. With Anaconda, you can easily run VSCode, Jupyter Lab, or a terminal with all the necessary configurations.
- Download and install Anaconda from anaconda.com.
- Once install completes, open Anaconda Navigator and click the Environments tab.
- Create a new environment for this course “Programming Lab A”. *Make sure to choose Python 3.7 or higher for the environment.
- After the environment is created, click on it and open the list of packages that are not installed from the drop-down menu.
- Check the boxes next to jupyterlab and notebook if you see them on the list.
- Click Apply and wait for the installation to complete.
- Return to the Home tab. You should now be able to launch JupyterLab.
Hello, Python!
After installing everything, try to get a simple Python program working so you can confirm that there are no problems with your environment.
- Open a terminal. If you installed piece-by-piece, this will be your computer terminal, such as Windows CMD. If you installed all-in-one, then open the Anaconda Navigator, make sure you have the “Programming Lab A” environment running, and click “Launch” on the CMD.exe Prompt or Powershell
- Type
python
and press enter to run the Python interpreter. This will show the Python prompt>>>
which means you can type Python code directly into the terminal. -
Type this line of code and press enter:
print("Hello, Python!")
- If you see the message echoed back to you, then everything is ready!
- Type
exit()
to back out of the Python interpreter.