0% found this document useful (0 votes)
4 views16 pages

1097 Ads Pythoninstallationinstructions

The document provides installation instructions for Python on Windows and macOS, recommending the use of Miniconda for a lean setup. It outlines the steps for verifying Python installation, installing Miniconda, and creating a new environment using conda. Additionally, it mentions an alternative method for installing Python directly without Anaconda and how to install packages using pip.

Uploaded by

Jhenkar Cm0316
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views16 pages

1097 Ads Pythoninstallationinstructions

The document provides installation instructions for Python on Windows and macOS, recommending the use of Miniconda for a lean setup. It outlines the steps for verifying Python installation, installing Miniconda, and creating a new environment using conda. Additionally, it mentions an alternative method for installing Python directly without Anaconda and how to install packages using pip.

Uploaded by

Jhenkar Cm0316
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Master of Science in Applied Data Science: Python

Installation Instructions on Windows & macOS

Python Installation Instructions


Python is supported on a range of operating systems. In general, Linux and macOS have Python
pre-installed. For other operating systems like Windows, Python can be downloaded from the
website (https://www.python.org/downloads/).

For this course, we will install Python through an open source data science package management
system called conda. It is developed by Anaconda, Inc. and runs on Windows, macOS and
Linux.

Python has two versions:


● Python 2.x
● Python 3.x
Of these two, Python 2 is older and is no longer supported or maintained by Python.org. So, we
will use the latest stable version of Python 3 that comes with the conda installer.

There are two types of conda installers:


Anaconda A full setup with IDE, GUI, CLI and scientific Needs 3GB+ disk space
packages

Miniconda Minimal installer with conda, Python and Needs 400MB disk space
dependencies

We recommend downloading Miniconda for its lean setup, it contains all the essential tools
required for this course. Additional Python packages can be easily installed using the conda or
pip package managers.

To download Miniconda, visit the url: https://docs.conda.io/en/latest/miniconda.html


Choose the installation file by
● your operating system - Windows or macOS
● your computer’s CPU bit size - 32 or 64 bit (most present day computers are 64 bit)
● Python 3.x version

Once you have the installation file downloaded to your computer, follow the below operating
system specific instructions.

Installation Steps: WINDOWS OS


● The first step is to verify if your computer already has Python installed. Here’s a simple
way to check that:
○ Open Command Prompt from the Windows Start menu
○ Type python --version and press Enter
○ If Python is installed, a version number will be returned
○ If Python is not installed, a blank line will appear

○ Remember this, as it will be useful later during Miniconda installation


● Now open the Miniconda installation file that you have downloaded to your computer
● A setup guide window will appear (similar to the below image), click Next.
● Click I Agree on the license agreement window and proceed to the next window.
● Choose the Just Me option on Install for window. This is important if you are installing
Miniconda on a work computer as you might not have the administrator privileges.
● Select the installation folder for Miniconda, we recommend the default option at:
C:\Users\<your-username>\Anaconda3\. Make sure not to have spaces in your filepath.

● The next step is an important part of the installation process.


○ Keep the first option “Add Miniconda3 to my PATH environment variable”
unchecked. You can always add Miniconda to the PATH at a later time if you find
it necessary to use conda from your Command Prompt, Powershell or GIT Bash.
For now you can use the CLI prompt provided by Miniconda.
○ The second option “Register Miniconda3 as my default Python” is selected by
default. You can keep this selected if this is your first Python installation and if
you want to use this Python version in other applications. If you already have
Python pre-installed and using it for other applications, then you might want to
uncheck this option as well.
● The next window will install Python, conda and other required dependencies.
This might take 1-2 minutes. Proceed to the Next window once installation is complete.
● Click Finish and exit setup. You can refer to the resources or opt out based on your
preference.

● Optionally, you can restart your computer now.

Verify Installation:
● Open Anaconda prompt from Windows Start menu.
● Enter conda list. If conda is installed and working, this will display a list of installed
packages and their versions.
● Enter the command python. This command runs the Python shell. If conda is installed
and working, the version information it displays when it starts up will include Anaconda.
To exit the Python shell, enter the command quit().

Create New Environment:


● With conda, you can create, export, list, remove, and update environments that have
different versions of Python and/or packages installed in them. The packages used in an
environment are bound to that environment and will not affect other projects. Switching
or moving between environments is called activating the environment.
● To create a basic environment for your course, use the command
conda create --name <environment_name>
For example: conda create --name ADS500B
● When conda asks you to proceed ([y]/n)?, type y for yes.
● To use this environment, it needs to be activated with the command: conda activate
ADS500B. You will notice that the environment switches from base to the newly
activated ADS500B.

● Use conda deactivate to deactivate the environment after use. The environment name is
not required for deactivation. But before you do that, let us install Jupyter within our
environment and test Python in a Jupyter notebook. To do that follow the instructions in
the Jupyter installation document.
Installation Steps: macOS
● Miniconda has two types of installation files for macOS:
○ Package file (.pkg) for GUI based installation
○ Shell file (.sh) for installation through Terminal
● Download either of these file types based on your preference.

Package File Installation (GUI):


● Open the installer file you have downloaded to your computer.
● Follow through the steps on the installer screen by agreeing to the license terms.

● Choose the default option Just Me on the Destination select window, this is important if
you do not have the administrator privileges for the computer. The default installation
path for GUI based installation is at /Users/<your-username>/opt folder.

● Continue through the installation, and close the installation window once complete.
Shell File Installation (CLI):
● Open the Terminal and navigate to the folder where the installation file is downloaded to.
● Run the bash command followed by the filename like:
bash Miniconda3-latest-MacOSX-x86_64.sh
● Follow through the screen prompts and agree to license terms by entering yes

● Next, select the default installation location by pressing ENTER key. Unlike the .pkg file,
the default path for shell installation is at: /Users/<your-username>

● The installer prompts “Do you wish the installer to initialize Miniconda3 by running
conda init?” Type yes.

● This will make changes to your bash_profile at: /Users/<your-username>/.bash_profile.


Once the installation is complete, close and reopen the Terminal.
Verify Installation:
● Whether you have installed Miniconda using GUI (.pkg file) or Terminal (shell file), you
need to open the Terminal to verify if conda and Python are installed.
● You might notice a prefix (base) before your computer name when you open the
Terminal. This means conda’s base environment is activated. If not, you can activate it
with the command: conda activate base
● Let’s confirm this by typing conda env list, which displays the list of environments, and
your current environment will be highlighted with an asterisk (*).
● Next, type python --version to verify the version of python installed through Miniconda,
which should be Python 3.x. Most macOS computers come pre-installed with a 2.7
version of Python.
● To exit out of your base environment, type: conda deactivate
● The conda base environment will be auto activated every time you open the Terminal. As
we will be creating a different environment for our course, you might want to turn the
auto activation off with the command: conda config --set auto_activate_base false

Create New Environment:


● With conda, you can create, export, list, remove, and update environments that have
different versions of Python and/or packages installed in them. The packages used in an
environment are bound to that environment and will not affect other projects. Switching
or moving between environments is called activating the environment.
● To create a basic environment for your course, use the command
conda create --name <environment_name>
For example: conda create --name ADS500B
● When conda asks you to proceed ([y]/n)?, type y for yes
● To use this environment, it needs to be activated with the command: conda activate
ADS500B. You will notice the prefix (ADS500B) when the environment is activated.
● Use conda deactivate to deactivate the environment after use. The environment name is
not required for deactivation. But before you do that, let us install Jupyter within our
environment and test Python in a Jupyter notebook.
Python installation without Anaconda (Windows 10)
1. Apart from this course, you can install Python directly without using Anaconda package
manager.
a. Download the latest Python 3 release from https://www.python.org/. Choose
either the web-based installer or the executable installer.
b. Run the installer. Select the option to Add Python 3.x to PATH.

2. Install Python packages using pip


a. Open a Command Prompt window

b. For example, enter the following command to install NumPy package:


pip install numpy
This will download and install the package.

You might also like