In the Installing Python Packages (Part 1) post, you discovered the easiest method of installing new packages when working with Beginning Programming with Python For Dummies, Python for Data Science for Dummies, and Machine Learning for Dummies. Using the pip command is both fast and easy. However, it doesn’t provide much in the way of feedback when things go wrong. To overcome this issue, you can use the conda command in place of pip when you have Anaconda installed on your system. Like pip, conda supports a wide variety of commands. You can find a listing of these commands at http://conda.pydata.org/docs/using/pkgs.html.
You need to know a few things about working with conda. The first is that you need to open an Anaconda prompt to use it. For example, when working with Windows, you use the Start ⇒ All Programs ⇒ Anaconda<Version> ⇒ Anaconda Prompt command to open a window like the one shown here where you can enter commands. (Your Anaconda Prompt may look different than the one shown based on the platform you use and the version of Anaconda you have installed.)
You can easily discover the features the conda command supports by typing conda -h and pressing Enter. You see a list of command line switches similar to the ones shown here:
As you can see, there are quite a few tasks you can perform. To determine whether you have a package installed, use the Conda search <package name> command. For example, if you want to determine if you have Pandas installed, you type Conda search Pandas and press Enter. You see a list of Pandas versions installed, assuming that Pandas is installed, like this:
The information you get from conda is far more in depth than pip provides. To determine what you have installed, just go down the list and determine whether you have the version of Pandas that you need. If you don’t, then type Conda update pandas and press Enter (notice the case used). On the other hand, let’s say you want to install BeautifulSoup. Well, the first time through, try typing Conda install BeautifulSoup and pressing Enter. You see an error message that tells you what to type like this:
Since you want to install the latest BeautifulSoup, type Conda install beautiful-soup and press Enter. After searching for the required update information, conda will ask if you want to proceed. Type y and press Enter. You’ll see a whole bunch of activity take place, but eventually, you have a new version of BeautifulSoup, plus all the supporting functionality, installed correctly in the correct locations. Here’s how things looked on my system:
At this point, you have BeautifulSoup installed. Installing other packages follows the same path. Using conda does require a little more expertise than using pip, but you also gain additional flexibility and garner more information. When everything goes well, either tool does an equally good job of getting the installation or update task done, but conda excels in helping you past troublesome installations. Let me know your thoughts about using conda to install the packages required by my books at John@JohnMuellerBooks.com.