H

Install Packages

There will be times when you have to install a Python package that did not come with your distribution. If you used Anaconda to install Python, then you will have a package manager called conda.

conda has gained popularity over the past few years because of its ability to install Python packages that require non-Python dependencies. You may have heard of other package managers, such as pip.

This book uses a few packages that need to be installed. If you installed the entire Anaconda distribution, then libraries like Pandas are already installed. But there’s no harm in running the command to reinstall a library. Check the accompanying repository1 for all the commands to install the relevant libraries for this book.

1. https://github.com/chendaniely/pandas_for_everyone

We can use conda to install Python libraries. If you created a separate environment for the book (Appendix G), then you can conda activate p4e to get into the “Pandas for Everyone” environment.

conda’s default repository is maintained by Anaconda, Inc (formerly known as Continuum Analytics). We can install the pandas package using conda.

# typed into your terminal, not in Python
conda install pandas

For certain packages that are not listed in the default channel, or if the default channel does not have the latest version of a package, we can use the and community-maintained conda-forge channel.2

2. https://conda-forge.org/

conda install -c conda-forge pandas

Lastly, if the package isn’t listed in conda, you can also use pip to install packages.

pip install pandas

For example, to install all the libraries used in this book, you can run the following lines:

conda install -c conda-forge pandas matplotlib pyarrow openpyxl 
  seaborn numba regex pandas-datareader statsmodels scikit-learn 
  arrow lifelines

Again, it’s a good idea to check the accompanying repository for the most recent installation and setup instructions.

H.1 Updating Packages

You can update conda itself with the following command:

conda update conda

Run this command to update all the packages in a given conda environment:

conda update --all
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.150.142