S.Carven
S.Carven

Reputation: 43

How can I install all dependencies for a specific python package?

When I install some python packages, pandas for example, I'd like to use the following command:

conda install pandas

This does install some denpendencies of pandas, BUT NOT ALL!

When I run the following code:

import pandas as pd

df = pd.DataFrame()
df.to_excel('a_excel_file.xlsx')

It gives me errors:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "D:\Miniconda\envs\to_be_deleted2\lib\site-packages\pandas\core\generic.py", line 2181, in to_excel
    engine=engine,
  File "D:\Miniconda\envs\to_be_deleted2\lib\site-packages\pandas\io\formats\excel.py", line 726, in write
    writer = ExcelWriter(stringify_path(writer), engine=engine)
  File "D:\Miniconda\envs\to_be_deleted2\lib\site-packages\pandas\io\excel\_openpyxl.py", line 18, in __init__
    from openpyxl.workbook import Workbook
  File "D:\PyCharm Professional 2019.1.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'openpyxl'

Looks like openpyxl were not installed as the installation of pandas. Why that happended? How to fix it?

Upvotes: 1

Views: 2593

Answers (1)

dspencer
dspencer

Reputation: 4481

openpyxl is an optional dependency of pandas, this is the reason why it wasn't installed when you installed pandas.

pandas has many such optional dependencies which add useful, but not core, features - see the installation documentation for a complete list.

Upvotes: 2

Related Questions