Installing Miniconda, Python, and Visual Studio Code - professorf/data-analytics GitHub Wiki
Python is a powerful, flexible programming language used in everything from data analysis to web development to artificial intelligence and machine learning. Before diving into it, we need to set up a package manager that will help us manage different libraries and versions of Python across various projects.
Miniconda is a lightweight package manager that makes this easy. Unlike simply installing Python directly, Miniconda lets you create isolated environments, manage dependencies, and maintain clean workspaces. This ensures you can work without worrying about version conflicts or other issues. In short, it gives you control over what packages you use and when you use them.
In this setup, we’ll install Miniconda to handle the packages and environments, then install Visual Studio Code as our integrated development environment (IDE). Finally, we’ll create a virtual environment to manage the specific version of Python we’ll be using for the course.
Part 1a: Installing Miniconda
A package is a collection of code that is usually written by someone else and shared with the development community, and it performs a useful function such as data storage, analysis, or visualization. A package manager makes a package accessible to your code and manages any updates made by the package developer. Python has two popular package managers: Pip and Conda. Conda is more flexible, as it allows you to manage both Python packages and system-level dependencies.
We'll be installing a version of Conda called Miniconda, which starts with a minimal set of packages, allowing you to install only what you need (as opposed to Anaconda, which includes many pre-installed packages).
-
Go to https://docs.anaconda.com/free/miniconda/miniconda-install/
-
Click on the graphical installer appropriate for your operating system (Windows, macOS, or Linux), and follow all installation instructions (selecting all default options).
Part 1b: Testing Miniconda
- Run the command line app Anaconda Prompt (miniconda3) (how you run depends on your OS):
2.Type conda init bash, which initializes Conda for use in your terminal and in Visual Studio Code, which we'll do next. This ensures that the Conda commands will work smoothly within your system's shell.
- Close and reopen your terminal for the changes to take effect. You can now test the installation by typing
conda list. If you see a list of installed packages, Miniconda has been successfully installed.
Using the Miniconda command line app can be cumbersome during development and analysis. Instead, we will use the Visual Studio Code integrated development environment (IDE) and perform any package management tasks within the IDE.
If you are reading this as part of one of my classes, take a screenshot and save it as Lastname-Firstname-conda.png
Part 2a: Installing the Visual Studio Code IDE
-
Click on the button to install the version appropriate for your operating system (Windows, Linux, or MacOS) and follow all installation instructions.
Part 2b: Testing Your Visual Studio Code Installation
- Run Visual Studio Code (how your run it depends on your OS):
Part 3: Setting up an Environment for Analytics
-
Create a new folder named
analytics, using your operating system's file manager; then open that folder in Visual Studio Code. Note: Your screen will look different from mine as I have been using Visual Studio Code for a while. -
Click View (menu) > Terminal (menu item). This brings up a terminal that you can use to create a conda environment, which will hold all the packages you will be using in this class.
-
Type conda create --name analytics python=3.12 and accept all defaults. This will create an environment named
analyticswith the latest version of python (3.12 as of the writing of this page) -
Type conda activate analytics
If you are reading this as part of one of my classes, take a screenshot and save it as Lastname-Firstname-vscode.png
Environments serve as dedicated spaces where you can store distinct sets of packages tailored to individual research projects. For instance, suppose you are conducting a research project on social networks. In this case, you might only need packages related to social network analysis. On the other hand, if you are working on an artificial intelligence (AI) research project, it would necessitate a different set of packages, specifically those designed for AI tasks. By using separate environments for each project, you can manage your packages more efficiently, ensuring that each project has access to the specific tools it needs without any unnecessary extras. This approach also helps prevent potential conflicts between packages required for different projects.
Note: You don't have to name both the folder and the environment analytics—I just did it for simplicity, especially if you're a beginner. Naming things clearly and the same helps keep everything organized and makes it easier to track what you're working on. Feel free to choose any name that fits your project or preferences.