如果pandas使用了xlsxwriter,为什么我想直接用的时候还要安装呢?

If pandas uses xlsxwriter why do I have to install it when I want to use it directly?

为什么我必须安装 xlsxwriterpip3 如果 pandas 并且我已经安装了 pandaspandas 是否只使用了它的一小部分依赖项?

首先,xlswriter 是 optional dependency 到 pandas 的 pandas 文档 here. Therefore, it is not installed automatically with pandas because it is not a necessary dependency. Also, you should know that xlsxwriter module is installed separately to write worksheets in an Excel 2007+ XLSX file. If this module is not installed before, pandas could not work and arise an error as you can see in this problem

最后,有时我们不需要手动安装xlsxwriter。例如,xlsxwriter 已安装 automatically with Anaconda,如记录 here