How To Install/Uninstall Python Packages In Anaconda Virtual Environment Successfully

There are 3 ways to install/uninstall python packages in anaconda, this article will tell you them one by one.

1. Install / Uninstall Python Packages In Anaconda Navigator Window.

1.1 Go To Anaconda Navigator Virtual Environment Python Packages List Window.

  1. If you use Windows, then click Windows Start Menu —> Anaconda3 —> Anaconda Navigator menu item to open it.
  2. Then click the Environments menu item in the opened Anaconda Navigator Window left menu list.
  3. Click to select one existing anaconda virtual environment in the middle environments list.
  4. Then you will find there is a drop-down list on the right panel top area.
  5. There are 5 drop-down items in the list, they are Installed, Not installed, Updatable, Selected, and All.
  6. There is also a Search Packages search box behind the drop-down list, you can search the python packages by input the search keyword and search.

1.2 Install Python Packages From Anaconda Navigator Python Packages List Window Steps.

  1. To install one python package, you can select the Not installed menu item from the drop-down list, then input the search keyword such as pandas in the Search Packages search box and click enter key.
  2. Then it will list all the python packages that the name contains the keyword pandas.
  3. Check the checkbox before the python packages to select them, then click the Apply button on the bottom right corner of the window to install it.
  4. It will popup an Install Packages window to display all the dependencies packages, then click the Apply button in the popup window to install them.

1.3 Uninstall Python Packages From Anaconda Navigator Python Packages List Window Steps.

  1. Select the Installed menu item from the above drop-down list.
  2. Input the installed python packages name in the Search Packages search box and click enter key to search it out.
  3. Click the checkbox before the python package, then it will pop up a menu list.
  4. Click the Mark for removal menu item in the above popup menu list, then the checkbox will be changed to a red square.
  5. After you select all the python packages that you want to remove, click the Apply button to remove them all.
  6. Then it will popup the Remove Packages window, it will list all the dependencies python library in the window. After you confirm it, you can click the Apply button in the Remove Packages window to remove them successfully.

2. Install / Uninstall Python Packages Through Conda Command.

  1. Open the Anaconda Navigator window, and click the Environments menu item in the window left side to list all the Anaconda virtual environments.
  2. Click the green triangle at the end of one anaconda virtual environment,  and then click the Open Terminal menu item in the popup menu list.
  3. It will open a dos window or a terminal window and enter your selected anaconda virtual environment.
  4. Run the command conda install package-name to install the python package like below.
    (MyPythonEnv) C:\Users\zhaosong>conda install Numpy
    Collecting package metadata (current_repodata.json): done
    Solving environment: done
    
    
    ==> WARNING: A newer version of conda exists. <== current version: 4.10.1 latest version: 4.10.3 Please update conda by running $ conda update -n base -c defaults conda ## Package Plan ## environment location: C:\Users\zhaosong\anaconda3\envs\MyPythonEnv added / updated specs: - numpy The following packages will be downloaded: package | build ---------------------------|----------------- certifi-2021.5.30 | py38haa95532_0 140 KB mkl-2021.3.0 | haa95532_524 113.7 MB mkl-service-2.4.0 | py38h2bbff1b_0 51 KB mkl_fft-1.3.0 | py38h277e83a_2 137 KB mkl_random-1.2.2 | py38hf11a4ad_0 225 KB numpy-1.20.3 | py38ha4e8547_0 23 KB numpy-base-1.20.3 | py38hc2deb75_0 4.2 MB openssl-1.1.1l | h2bbff1b_0 4.8 MB ------------------------------------------------------------ Total: 123.3 MB The following NEW packages will be INSTALLED: blas pkgs/main/win-64::blas-1.0-mkl intel-openmp pkgs/main/win-64::intel-openmp-2021.3.0-haa95532_3372 mkl pkgs/main/win-64::mkl-2021.3.0-haa95532_524 mkl-service pkgs/main/win-64::mkl-service-2.4.0-py38h2bbff1b_0 mkl_fft pkgs/main/win-64::mkl_fft-1.3.0-py38h277e83a_2 mkl_random pkgs/main/win-64::mkl_random-1.2.2-py38hf11a4ad_0 numpy pkgs/main/win-64::numpy-1.20.3-py38ha4e8547_0 numpy-base pkgs/main/win-64::numpy-base-1.20.3-py38hc2deb75_0 The following packages will be UPDATED: ca-certificates 2021.4.13-haa95532_1 --> 2021.9.30-haa95532_1
      certifi                          2020.12.5-py38haa95532_0 --> 2021.5.30-py38haa95532_0
      openssl                                 1.1.1k-h2bbff1b_0 --> 1.1.1l-h2bbff1b_0
    
    
    Proceed ([y]/n)? y
    
    
    Downloading and Extracting Packages
    numpy-1.20.3         | 23 KB     | ################################################################################################################################################################################################# | 100%
    openssl-1.1.1l       | 4.8 MB    | ################################################################################################################################################################################################# | 100%
    certifi-2021.5.30    | 140 KB    | ################################################################################################################################################################################################# | 100%
    mkl-service-2.4.0    | 51 KB     | ################################################################################################################################################################################################# | 100%
    numpy-base-1.20.3    | 4.2 MB    | ################################################################################################################################################################################################# | 100%
    mkl_fft-1.3.0        | 137 KB    | ################################################################################################################################################################################################# | 100%
    mkl_random-1.2.2     | 225 KB    | ################################################################################################################################################################################################# | 100%
    mkl-2021.3.0         | 113.7 MB  | ################################################################################################################################################################################################# | 100%
    Preparing transaction: done
    Verifying transaction: done
    Executing transaction: done
    
  5. After you successfully install the python package, you can run the command conda list package-name to verify that it has been installed.
    (MyPythonEnv) C:\Users\zhaosong>conda list Numpy
    # packages in environment at C:\Users\zhaosong\anaconda3\envs\MyPythonEnv:
    #
    # Name                    Version                   Build  Channel
    numpy                     1.20.3           py38ha4e8547_0
    numpy-base                1.20.3           py38hc2deb75_0
    
  6. To uninstall a python package, you can run the command conda uninstall package-name.
    (MyPythonEnv) C:\Users\zhaosong>conda uninstall Numpy
    
  7. You can run the command conda list package-name again to verify the uninstall result.
    (Python27) C:\Users\zhaosong>conda list Numpy
    # packages in environment at C:\Users\zhaosong\anaconda3\envs\Python27:
    #
    # Name                    Version                   Build  Channel

3. Install / Uninstall Python Packages Through PIP Command.

  1. Run the command pip install package-name to install the python package as below.
    (MyPythonEnv) C:\Users\zhaosong>pip install Numpy
    Collecting Numpy
      Downloading numpy-1.21.2-cp38-cp38-win_amd64.whl (14.0 MB)
         |████████████████████████████████| 14.0 MB 1.6 kB/s
    Installing collected packages: Numpy
    Successfully installed Numpy-1.21.2
  2. After you install the python package, you can run the command pip show Numpy to verify the python package installation.
    (MyPythonEnv) C:\Users\zhaosong>pip show Numpy
    Name: numpy
    Version: 1.21.2
    Summary: NumPy is the fundamental package for array computing with Python.
    Home-page: https://www.numpy.org
    Author: Travis E. Oliphant et al.
    Author-email:
    License: BSD
    Location: c:\users\zhaosong\anaconda3\envs\mypythonenv\lib\site-packages
    Requires:
    Required-by:
  3. To uninstall the python package, just run the command pip uninstall package-name.
    (MyPythonEnv) C:\Users\zhaosong>pip uninstall Numpy
    Found existing installation: numpy 1.21.2
    Uninstalling numpy-1.21.2:
      Would remove:
        c:\users\zhaosong\anaconda3\envs\mypythonenv\lib\site-packages\numpy-1.21.2.dist-info\*
        c:\users\zhaosong\anaconda3\envs\mypythonenv\lib\site-packages\numpy\*
        c:\users\zhaosong\anaconda3\envs\mypythonenv\scripts\f2py.exe
    Proceed (Y/n)? Y
      Successfully uninstalled numpy-1.21.2
    (MyPythonEnv) C:\Users\zhaosong>pip show  Numpy
    WARNING: Package(s) not found: Numpy

References

  1. How To Fix ValueError: Check_hostname Requires Server_HostName
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Clicky
0
Would love your thoughts, please comment.x
()
x