How do I reinstall Anaconda Python

How do I reinstall Anaconda Python

Anaconda is a popular Python distribution that includes a variety of tools and packages for computing, data analysis, and machine learning. Sometime, We need to reinstall Anaconda due to various reasons, Like upgrade failure, or to fix an installation issue or migrating to a new Machine. In this article, we will provide you with a step-by-step guide on how to reinstall Anaconda with examples.

How do I reinstall Anaconda Python

Step 1: Uninstall the current version of Anaconda

Before you can reinstall Anaconda, you need to uninstall the current version of Anaconda on your system. The steps for uninstalling Anaconda will vary depending on your operating system.

For Windows users:

  • Go to your Control Panel and click on “Programs and Features”.
  • Find Anaconda in the list of installed programs, and click on “Uninstall”.
  • Follow the prompts to complete the uninstallation process.

For macOS and Linux users:

  • To remove all traces of the configuration files and directories from Anaconda, We need to follow the below steps

Open Terminal -> Install the anaconda-clean package:

conda install anaconda-clean
  • Run the below command to remove all Anaconda-related files and directories
anaconda-clean --yes

anaconda-clean leaves your data files in the AnacondaProjects directory untouched.

  • Once the above steps have been completed, We can remove the Anaconda directory and Remove the Anaconda path from .bash_profile
rm -rf anaconda3
rm -rf ~/anaconda3
rm -rf ~/opt/anaconda3

Delete the “export PATH=”/Users/jsmith/anaconda3/bin:$PATH” from.bash_profile or .zprofile file from your home directory

anaconda distribution

Step 2: Download the latest version of Anaconda

Once you have uninstalled the previous version of Anaconda, you can download the latest version of Anaconda from the official website. Go to https://www.anaconda.com/products/distribution and select the appropriate version for your operating system.

install anaconda 3

I am using Mac, So I will go ahead and download the Anaconda Mac version: Anaconda3-2023.03-1-MacOSX-x86_64

Step 3: Install Anaconda

After downloading the Anaconda installation file, follow these steps to install Anaconda:

  • Double-click on the installation file to start the installation process.
  • Follow the prompts in the installation wizard to choose the installation directory and the packages you want to install. You can choose the default options if you’re unsure.
install anaconda
  • Wait for the installation to complete.
install successfully

Step 4: Verify the installation

Hope you have installed Anaconda successfully, Post installing Anaconda, you can verify the installation by opening a new terminal or command prompt window and typing “conda list“. This will show you a list of all the packages installed in your Anaconda environment.

For example, if you type “conda list” in a terminal window on macOS or Linux, you should see an output similar to the following:

~ % conda list | grep -i anaconda
# packages in environment at /Users/User1/anaconda3:
anaconda-client           1.11.2          py310hecd8cb5_0  
anaconda-navigator        2.4.0           py310hecd8cb5_0  
anaconda-project          0.11.1          py310hecd8cb5_0  

NOTE: Open a fresh terminal window, To reflect the latest installation

If you are still having trouble executing conda command, Check your “cat .bash_profile” file for any entry related to conda path else you can manually add the path as below

export PATH="/Users/user1/anaconda3/bin:$PATH"

Hurray!!. This indicates that Anaconda has been successfully installed on your system.

How to use Anaconda for Python

We can try a few fundamental steps to check if the Anaconda has been installed properly and will try out few python examples in Anaconda Environment.

Create Anaconda Environment

# Creating a New Environment
% conda env list 
# conda environments:
#
base                  *  /Users/user1/anaconda3

# Name your Env
% conda create -n learnshare             
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /Users/jxavier/anaconda3/envs/learnshare

Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate learnshare
#
# To deactivate an active environment, use
#
#     $ conda deactivate

# Activate your environment
% conda activate learnshare        
(learnshare) 

Ran Sample Code

Once you could above to create and activate the Anaconda environment, We can able to run Python code using Anaconda

Anaconda Python Version

(learnshare) % python --version

Python 3.10.9

(learnshare)  ~ % python
Python 3.10.9 (main, Mar  1 2023, 12:33:47) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> Sum=100 + 200
>>> print(Sum)
300
>>> 

(learnshare) % conda deactivate

Normal Python Version

user1@% python --version

Python 2.7.16

Conclusion

Reinstalling Anaconda is a simple process that you can complete in a few steps. By following the steps outlined in this guide, you should be able to successfully reinstall Anaconda on your system.

Read More:

Fix – TypeError: tuple indices must be integers or slices not str

How to convert RGB to Hex and Hex to RGB code in Python

How to Make Jarvis With Dialogflow and Python

How do I print an empty line in Python?

Coding Spell Python Journey | About Us 

Latest posts by Muhammad Usman Shafique (see all)