1. Installing Python Libraries
Installation of libraries needed for this book
-
Open a command line:
- On Windows PCs, press the Windows key, then type
cmdand press Enter. - On Macs, hold the “command” key, press the space bar, and type Terminal, then press “return.”
- On Windows PCs, press the Windows key, then type
-
Your base Python installation includes the program pip to install packages.
- On Windows PCs, the command for pip is just
pip - On Macs, the command for pip is most often
pip3In the command line that you just opened type the appropriate command, which should give you an output that looks like:
C:\Users\Chris>pip Usage: pip <command> [options] Commands: install Install packages. download Download packages. uninstall Uninstall packages. freeze Output installed packages in requirements format. inspect Inspect the python environment. list List installed packages. show Show information about installed packages. check Verify installed packages have compatible dependencies. config Manage local and global configuration.If you get this, or something like it, then pip is working correctly and you are ready to install packages. If not, you will need to troubleshoot.
- On Windows PCs, the command for pip is just
-
You install packages with pip by typing
pip install <package_name>(for Macs,pip3 install <package_name>). Type the following command, usingpip/pip3as appropriate:pip install spyder numpy scipy plotly lmfit rdkit python-docx openpyxl pillow codechembookThis may take a few minutes. -
Next, you will need to install a package called “kaleido” that handles outputting images of plots. You should use a different version depending on your computer:
- On a Windows PC,
pip install kaleido - On a Mac,
pip3 install kaleido
- On a Windows PC,
-
Type
pip list(on Macs,pip3 list) to find out which versions of the packages you have. Check to make sure that the following packages are listed and their version numbers are at least:- numpy (version 1.26.4 or greater - see note if your version starts with 2[^3])
- scipy (version 1.13.1 or greater)
- plotly (version 6.1.0 or greater)
- spyder (version 5.5.1 or greater)
- kaleido (version 1.0.0 or greater)
-
Type
spyderinto the command line to start up the Spyder IDE, and ensure that it opens. If it does, then all should be well, and you can close it. If not, you will need to troubleshoot.1
-
As of August 2025, some users (particularly with Macs) see an error on trying to start Spyder:
ModuleNotFoundError: No module named 'distutils'. This can usuall be fixed by going back to the command line in Terminal and typingpip3 install setuptools, which should allow spyder to launch. You may have to close and repoen your ternimal before retrying spyder. ↩︎