Codecademy’s learning environment allows you to enter Python code and receive feedback on whether or not the code you entered is correct for a given exercise. In this article, we’ll walk you through how to install Python so that you can write and run Python code outside of Codecademy and on your computer!
Why build outside of Codecademy?
The programming world is massive, and it’s impossible to teach everything in one place. Although Codecademy excels at teaching you how to code via interactive lessons, we’d also like for you to learn how to code on your computer so that you can create personal projects (and perhaps share them with the world)!
How long does installing Python take?
Creating a development environment for yourself on your own computer is important so that you can continue to build upon your Python knowledge outside of the Codecademy platform. Unfortunately, every computer is different and some take a long time to troubleshoot. You should budget no less than 2 hours in order to go through this installation process. If you happen to get through it faster, that’s great. But, since this article can only offer general instructions, you may need to do some investigation and research about how to get Python to run on your computer. Be prepared, and after you get through this you’ll be ready to take on the world.
In this article, we’ll cover the following topics:
- What is Anaconda?
- What is Miniconda?
- Should I Install Anaconda, Miniconda, or just Python?
- Installation: Python
- Running Python Code
- Installing and Managing Python Packages Using
- Installation: Miniconda
- Was the Installation Successful?
- Managing Packages in Anaconda / Miniconda
What is Anaconda?
Anaconda is an open-source Python distribution for large-scale data analytics (provided by Continuum Analytics, Inc.). It additionally provides you with many of the tools you need to analyze large sets of data. When installed,
- The core Python language (you can use which version)
- Over 1000 packages, many for data science
- Package management with
- Much more
What is Miniconda?
Miniconda is a slimmed-down version of Anaconda. The Anaconda download is large (a few gigabytes) and can take quite some time to download and install. Miniconda, on the other hand, is a smaller alternative. It includes only the basic requirements and allows you to install packages as-needed, thereby decreasing the size and time of the download.
Should I Install Anaconda, Miniconda, or just Python?
Both Anaconda and Miniconda also install Python, so you can install Anaconda, Miniconda, or Python.
Anaconda and Miniconda make it easier to install Jupyter notebooks, which we make extensive use of at Codecademy. It’s possible to install Jupyter without any additional software on top of your Python installation. Installing Python vs. Anaconda vs. Miniconda is ultimately your choice. We recommend installing Miniconda to decrease the amount of time required to set up everything.
To install Python, follow these steps:
Navigate to the Python downloads page: Python downloads.
Click on the link/button to download Python 3.6.x.
Follow the installation instructions (leave all defaults as-is).
Open your terminal again and type the command
cd. Next, type the command
python. The Python interpreter should respond with the version number. If you’re on a Windows machine, you will likely have to navigate to the folder where Python is installed (for example,
Python36, which is the default) for the
python3 command to function.
Running Python Code
Congrats! You should have Python 3.6 installed now. Let’s run some Python code!
- Open your terminal and type
cd (if you’re using Windows, navigate to the
Python36 folder instead).
- Create a file called
mycode.py (make sure it has a
mycode.py using your favorite text editor.
- Add the following code to the file and save it:
print("I'm running Python code on my own!")
5. In your terminal, type the following command and press “Enter” (or “Return”) on your keyboard to run your code (again, if you’re on Windows you will need to navigate to the folder you installed Python 3.6 in):
6. Your terminal should output the following message:
I'm running Python code on my own!
Congratulations! You just ran Python code on your computer!
Installing and Managing Python Packages Using
With Python, you can build just about anything, from simple scripts to full applications. The Python language, however, doesn’t come pre-installed with all of the fancy features you might want (or require). When you need particular functionality, you can look toward Python packages. A package structures Python modules, which contain pre-written code that other developers have created for you. Modules are handy when you are looking for specific functionality.
You can use
pip3, Python’s package manager, to install and manage Python packages.
pip3 gets installed along with Python.
You can use
pip3 to install packages, like so:
pip3 install jupyter
In the example above,
pip3 will install the Jupyter package, a popular package (among many) used for creating “notebooks” for running Python.
There are a multitude of Python packages, which you can find on PyPI — the Python Package Index — the official repository for third-party software for the Python programming language. PyPI is where
pip3 grabs Python packages from when you use
pip3 to install a new package on your computer.
You can use
pip3 for a variety of other things as well, which you can learn about through a quick search on the web.
To install Miniconda, follow these steps:
Navigate to the Miniconda download page: Miniconda
Select the Python 3.6 installer for your computer’s operating system.
Locate the installer that you downloaded using Explorer (Windows) or Finder (Mac OS).
Run the installer. Use the following instructions based on your computer’s operating system:
You may receive a notification about XCode requiring additional component. Click “Install” and enter your password to proceed.
Open your terminal and navigate to the folder where you downloaded the installer. Type the following command in the terminal and press “Return” on your keyboard:
miniconda-filename.sh is a fictional file name in the example above. Your file name will look something like
3. Follow all instructions in the terminal (you can press
Enter as-needed and type
yes when necessary).
- Follow the installation instructions provided by the installer.
Was the Installation Successful?
To test whether your installation was successful (regardless of your computer’s operating system), type the following command into your terminal:
You should see a list of all the packages that Miniconda installed. If you’re on a computer that uses Windows, you may have to first navigate to the folder where you installed Miniconda for the
conda list command to function properly.
If it works out, you can install Jupyter notebooks by running the following command:
conda install jupyter
Congrats! You now have Miniconda (with Python 3.6) installed on your computer as well as Jupyter notebooks. You’re ready to code!
Managing Packages in Anaconda / Miniconda
With Python, you can build just about anything, from simple scripts to full applications. The Python language, however, doesn’t come pre-installed with all of the fancy features you might want (or require), even when installed using Anaconda or Miniconda. When you need particular functionality, you can look toward Python packages. A package structures Python modules, which contain pre-written code that other developers have created for you. Modules are handy when you are looking for specific functionality.
pip3 is used to install and manage Python packages. It is the package manager for the official Python distribution. If you installed Python with Anaconda or Miniconda, however, the package manager is not
pip3, the package manager is
To learn more about
conda, visit the Conda documentation at the following link:
pip vs. conda
conda is the package manager for Anaconda (and Miniconda),
pip3 is also included with Anaconda (and Miniconda). Certain packages will not be available from
conda or Anaconda.org. When this happens, you can use
pip3 to install packages.
Be careful when using
pip3, though. Using
pip3 to install packages available to
conda can result in installation errors.
So far, you’ve been writing Python code on Codecademy. Your learning journey, however, is not complete unless you can also write Python code outside of Codecademy, on your computer. If you want to run your own Python programs, we recommend installing Miniconda (with Python 3.6), and then using
conda to install certain packages. Have fun coding!