Installing Python 3 on macOS:
- Check if Python is already installed. Open the Terminal and type:
python3 --versionIf Python 3 is installed, you'll see the version number. If not, proceed with the installation.
- Install Python 3 using Homebrew. Homebrew is a popular package manager for macOS. Execute the following command to install Python 3 by Homebrew:
brew install python- After installation, verify that Python 3 is installed by checking the version again:
python3 --versionInstalling Python 3 on Linux:
- Update the package list. Open a Terminal window and update your package list:
sudo apt update- Install Python 3. For Debian-based systems like Ubuntu, use:
sudo apt install python3- Verify the installation. Check if Python 3 is installed by running:
python3 --version- Check if pip3 is already installed. Open the Terminal and type:
pip3 --versionIf it's already installed, you'll see the version number.
- Install pip3 using Homebrew. If pip3 isn't installed, and you have Homebrew installed, you can install pip3 by installing Python 3 (since pip3 comes bundled with Python 3):
brew install pythonInstalling pip3 on Linux:
- Update the package list. Open a Terminal window and update your package list:
sudo apt update- Install pip3. For Debian-based systems like Ubuntu, use:
sudo apt install python3-pip- Verify the installation. Check if pip3 is installed by running:
pip3 --versionAlternative Installation Method: Using get-pip.py
If pip3 is not available in your package manager, you can use the get-pip.py script to install it manually:
- Download ``get-pip.py```:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py- Run the script with Python 3:
python3 get-pip.py- Verify the installation:
pip3 --versionStep 1: Download the Miniconda Installer.
- Choose the appropriate Miniconda installer:
- Visit the Miniconda download page and choose the macOS installer for Python 3.
- Download the
.pkginstaller for macOS.
Step 2: Install Miniconda.
-
Run the installer:
- Locate the downloaded
.pkgfile (usually in your Downloads folder) and double-click it to run the installer and follow the installation prompts to install Miniconda.
- Locate the downloaded
-
Complete the installation:
- After the installation completes, you should see a confirmation screen. Click
Closeto exit the installer.
- After the installation completes, you should see a confirmation screen. Click
Step 3: Verify the Installation
-
Verify the Conda installation:
- Type the following command in the Terminal and press Enter:
conda --version
- You should see the version of Conda that you installed, indicating that the installation was successful.
- Type the following command in the Terminal and press Enter:
-
Optional Step: You can customize your Conda experience by setting the CONDA_HOME environment variable to point to the Miniconda installation directory.
export CONDA_HOME=/opt/miniconda3
export PATH="$CONDA_HOME/bin:$PATH"By default, when you install Miniconda, it will be located in: /opt/miniconda3.
Step 4: Initialize Conda
-
Initialize Conda for your shell:
- Run the following command in the Terminal to initialize Conda:
conda init
- This command configures your shell to use Conda.
- Run the following command in the Terminal to initialize Conda:
-
Restart your Terminal:
- Close and reopen your Terminal to apply the changes.
Step 5: Create and Manage Conda Environments
- Create a new environment:
- To create a new Conda environment, use the following command:
conda create --name ai_book_env
ai_book_envwill be our enviroment for developing applications.
- To create a new Conda environment, use the following command:
- Activate the environment:
- To activate the environment, use the following command:
conda activate ai_book_env
- To activate the environment, use the following command:
- Deactivate the environment:
- To deactivate the environment, use the following command:
conda deactivate
- To deactivate the environment, use the following command:
Step 6: Additional Configuration (Optional)
- Configure Conda channels:
- Conda uses channels to find packages. You can add additional channels if needed. For example, to add the
conda-forgechannel:conda config --add channels conda-forge
- Conda uses channels to find packages. You can add additional channels if needed. For example, to add the
- Update Conda:
- It's a good idea to keep Conda up to date. You can update Conda with the following command:
conda update conda
- It's a good idea to keep Conda up to date. You can update Conda with the following command: