Installing Python 3 and Python Packages
Installing Python 3 and Python Packages
Learning a newprogramminglanguage, such as Python, on the Codecademy platform is super convenient and a ton of fun! Sooner or later the time will come when you desire to build your own projects and continue learning on your own computer. If you are ready to take things to the next level and can invest about an hour of your time installing and setting up your own Python development environment, then this article is for you!
By the end of this article, we will understand the difference between the standard Python distribution and alternatives, such as Anaconda and Miniconda, and how to install each on Mac and Windows. We will also learn what a package manager is and how to install packages usingpipandconda. Lastly, we willinstall the Jupyter Notebook packageso we can create and share interactive Python notebooks.
If you have a Chromebook, we have a separate article toteach you how to install Python 3as well as an article toteach you how to install Jupyter Notebookon your Chromebook device.
Before we begin, this article assumes that you are familiar with the basics of the command line and can execute simple commands just as moving around between files and folders in your file system. If needed, be sure to checkout the freeLearn the Command Linelesson for a quick refresher!
At its heart, Python is a general purpose programming language that is often regarded as both easy to learn and very user-friendly. While Python is great for scripting and writing “glue” code to integrate existing components together, it is also a powerful full-fledged language that is capable of solving pretty much any software problem.Popular applications of Pythoninclude web applications, data analysis, and machine learning.
While Python itself is just a programming language, a Python distribution bundles the core language with various other libraries and packages generally geared toward a specific problem domain (such as Data Analytics or Web Development). The standard Python distribution is released onpython.organd includes the Python standard library as well as the package managerpip.
Though the list of Python distributions is always growing, two other popular distributions are Anaconda and Miniconda. The next section introduces both of these distributions, the pros and cons for each, and a recommendation on which to install.
Anaconda is anopen sourcePython distribution that is purpose built for data science, machine learning, and large-scale data processing. It includes the core Python language, over 1,500 data science packages, a package management system calledconda, IPython (an interactive Python interpreter), and much more. While it is a very comprehensive distribution, it is also quite large and therefore can take a while to download and consumes a lot of disk space.
Miniconda on the other hand, is a slimmed down version of Anaconda and includes all of the same components except for the pre-installed 1,500 data science packages. Instead, we can simply install these packages individually as needed usingconda(the Anaconda/Miniconda package manager). We essentially get all the benefits of Anaconda, but without the hassle and burden of the large size. Feel free to use either distribution, however Miniconda is probably the better choice for getting set up with the least amount of fuss.
While Python the language is a great tool, a huge benefit of the Python is the large ecosystem and plethora of reusable packages (sometimes called libraries) that other developers maintain and share for anyone’s use. A package manager is the tool by which packages can be downloaded, installed, and managed within your projects. It is also responsible for keeping track of package versions anddependencies, packages that we don’t install ourselves but are imported by the package we’re installing. Even though a package manager is a complex tool, they are very simple to use.
Similar to how there are many different Python distributions, there are also several different package managers available. Despite having several options, most package managers function in the same manner and use a simple command structure. Each Python distribution is usually bundled with a specific package manager. Some of the more common ones arepipandconda.
Good question! Now that the differences between Python distributions is clear, you are probably wondering which is the best distribution for you to install. There really is no right answer here, since each distribution is designed for varying needs. If you are interested in data science or machine learning then starting with Miniconda is a good choice. Otherwise, beginning with the standard Python distribution is a good choice for learning Python in general. You can always install the packages you need later.
Regardless of what you decide, keep in mind that you really only need to install a single Python distribution (and not several). So select your pick below and follow the corresponding installation instructions. Also keep in mind that there are a handful of different ways to install each of these Python distributions, however the instructions below are the easiest way to get started!
Most modern versions of MacOS come pre-installed with Python 2, however Python 3 is now the standard and should be installed as well. Python 3 can be installed using the official Python 3 installer.
- Go to thePython Releases for Mac OS Xpage and download the latest stable release macOS 64-bit/32-bit installer.
- After the download is complete, run the installer and click through the setup steps leaving all the pre-selected installation defaults.
- Once complete, we can check that Python was installed correctly by opening a Terminal and entering the commandpython3 --version. The Python 3.13.0 version number should print to the Terminal.Note: This version will change as new releases come out.AdvancedSince our system now has both Python 2 (which came pre-installed) and Python 3, we must remember to use thepython3command (instead of justpython) when running scripts. If you would rather not have to remember thepython3command and just usepythoninstead, then creating a command alias is your best bet.
- Executeopen ~/.bash_profilefrom a Terminal (if the file was not found, then runtouch ~/.bash_profilefirst).
- Copy and pastealias python="python3"into the now open.bash_profilefile and save.
- While we’re at it, go ahead and copy and pastealias pip="pip3"into the file as well in order to create an alias for the Python 3pippackage manager.
- Finally, restart the Terminal and runpython --version. We should see the exact same output as runningpython3 --version.
Follow the below steps to install Python 3 on Windows.
- Go to thePython Releases for Windowspage and download the latest stable release Windows x86-64 executable installer.
- After the download is complete, run the installer.
- On the first page of the installer, be sure to select the “Add Python to PATH” option and click through the remaining setup steps leaving all the pre-select installation defaults.
- Once complete, we can check that Python was installed correctly by opening a Command Prompt (CMD or PowerShell) and entering the commandpython --version. The Python 3.13.0 version number should print to the console.Note: This version will change as new releases come out.
Follow the below instructions to install the latest Miniconda version for Mac.
- Go to theMiniconda Downloadpage and download the Python 3.13.0 Mac OS X 64-bit.pkginstaller.Note: This version will change as new releases come out.
- After the download is complete, run the installer and click through the setup steps leaving all the pre-selected installation defaults.
- Once complete, we can check that Miniconda was installed correctly by opening a Terminal and entering the commandconda list. This will print a list of packages installed by Miniconda.
Follow the below instructions to install the latest Miniconda version for Windows.
- Go to theMiniconda Downloadpage and download the Python 3.13.0 Windows 64-bit.exeinstaller.Note: This version will change as new releases come out.
- After the download is complete, run the installer and click through the setup steps leaving all the pre-selected installation defaults.
- Once complete, we can check that Miniconda was installed correctly by opening a Command Prompt (CMD or PowerShell) and entering the commandconda list. This will print a list of packages installed by Miniconda.
With a Python installation complete, let’s try out our new development environment by writing and executing our first script.
- Open a Terminal (if on Mac) or Command Prompt (if on Windows) and browse to a directory of your choice.
- Create a new file calledmycode.pyand open it with your favorite text editor.
- Copy and paste the following code and save the file.print("I'm running Python code on my own environment!")Copy to clipboard
- Finally, run the script by executing the following command from the Terminal/Command Prompt in the folder where the file was saved.python mycode.pyCopy to clipboard
- Our console should print the following messageI'm running Python code on my own environment!.Copy to clipboard
- That’s it! We just ran Python code on our own personal environment.
print("I'm running Python code on my own environment!")
Copy to clipboard
print("I'm running Python code on my own environment!")
python mycode.py
Copy to clipboard
python mycode.py
I'm running Python code on my own environment!.
Copy to clipboard
I'm running Python code on my own environment!.
Now that we have a Python distribution installed and were able to run some Python code, let’s install theJupyter Notebookpackage. Jupyter Notebook is an open-source web application that allows us to create and share documents that contain live code, equations, visualizations and narrative text. This is a fantastic way to both learn and share Python code and the installation is made easier by our package installer! The installation steps differ depending on which Python distribution we installed above, so be sure to jump to the appropriate section. If you have both pip and Miniconda installed, we recommend using Miniconda to install the Jupyter Notebook package.
Follow the below instructions to install the Jupyter Notebook package using the Miniconda package managerconda.
- Open a new Terminal (Mac) or Command Prompt (Windows).
- Runconda install jupyterto download and install the Jupyter Notebook package.
- Once complete, we can check that Jupyter Notebook was successfully installed by runningjupyter notebookfrom a Terminal (Mac) / Command Prompt (Windows). This will startup the Jupyter Notebook server, print out some information about the notebook server in the console, and open up a new browser tab tohttp://localhost:8888
Follow the below instructions to install the Jupyter Notebook package using thepipPython package manager.
- Open a new Terminal (Mac) or Command Prompt (Windows).
- Runpip install jupyterto download and install the Jupyter Notebook package.
- Once complete, we can check that Jupyter Notebook was successfully installed by runningjupyter notebookfrom a Terminal (Mac) / Command Prompt (Windows). This will startup the Jupyter Notebook server, print out some information about the notebook server in the console, and open up a new browser tab athttp://localhost:8888.
Congratulations, you now have a fully functioning Python environment running on your own computer and have taken the next step in your Python journey. Have fun and don’t forget to check out the manyPython coursesavailable right here at Codecademy!
'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'
Complete Payment to Unlock Full Guide & Source Code
You are viewing the 30% preview. Join TopCourseAI Pro to unlock the remaining 70% of this article, unblur all code snippets, and gain full access to all 412 technical projects and guides.
Ready to access the complete step-by-step tutorial?
Gain full unhindered access to all 412 technical projects and guides, unblur all source code snippets, and download runnable scripts.
Installing Jupyter Notebook on a Chromebook
Next BlueprintInstalling and Setting up Xcode
Related Blueprints & Guides
View all 166 →Android Studio Quick-Start Guide
Android Studio often intimidates beginners, but by learning a few handy shortcuts and getting the lay of the land, we can navigate this powerful development environment with ease.
Developer toolsApache Kafka Tutorial: A Complete Guide for Beginners
Apache Kafkais a well-known distributed event streaming platform designed to efficiently manage real-time data feeds. It was originally developed by LinkedIn in 2011 and later open-sourced. Apache Kafka has gained immens...
Developer toolsBuilding Websites with Wix
Creating a website has never been easier. Previously, making a presentable website meant learning HTML, CSS, andJavaScript. The whole process could take weeks, months, or even years before creating a website that you’re...
Ready to build production-grade AI systems?
Enjoyed this guide? Continue exploring our library of 166+ production blueprints, multi-agent swarms, and autonomous agent systems with 100% unblurred, executable source code.