To set up Python and Anaconda on a Mac
1. Installing Anaconda
Anaconda includes Python and a suite of data science libraries, along with environment management tools.
Steps:
- Visit the official Anaconda website: https://www.anaconda.com/products/distribution
- Download the macOS installer (choose the Python 3.x version).
- Open the downloaded
.pkgfile and follow the on-screen instructions to install Anaconda. - Once installed, open Terminal and verify:
This should display the installedconda --versioncondaversion.
2. Configure Environment (Optional but Recommended)
- To create a new Python environment:
conda create -n myenv python=3.9 - Activate the environment:
conda activate myenv - To install additional packages (e.g., NumPy, pandas):
conda install numpy pandas
3. Installing Python via Miniconda (Lightweight alternative)
- If you prefer a minimal setup, install Miniconda from https://docs.conda.io/en/latest/miniconda.html
- Follow similar steps to install and create environments.
4. Using Python Without Anaconda
- macOS comes with Python pre-installed, but it’s usually an older version.
- To install the latest Python:
- Download from https://python.org
- Run the installer and follow prompts.
- Verify:
python3 --version
- Use
pipto install libraries:pip3 install numpy pandas
Additional Tips
- Integrated Development Environment (IDE): Use VSCode, PyCharm, or Jupyter Notebooks (included with Anaconda).
- Launching Jupyter Notebook:
conda activate myenv jupyter notebook - Environment Management: Always use environments to package dependencies, avoiding conflicts.
- Updating Anaconda:
conda update conda conda update anaconda