1
resposta

[Dúvida] problema ao importar tabela pelo excel

df_xlsx = pd.read_excel('extras/aluguel.xlsx')
df_xlsx
Output exceeds the size limit. Open the full output data in a text editor
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
File c:\Users\oberg\miniconda3\envs\myenv\lib\site-packages\pandas\compat\_optional.py:141, in import_optional_dependency(name, extra, errors, min_version)
    140 try:
--> 141     module = importlib.import_module(name)
    142 except ImportError:

File c:\Users\oberg\miniconda3\envs\myenv\lib\importlib\__init__.py:126, in import_module(name, package)
    125         level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)

File :1050, in _gcd_import(name, package, level)

File :1027, in _find_and_load(name, import_)

File :1004, in _find_and_load_unlocked(name, import_)

ModuleNotFoundError: No module named 'openpyxl'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
Cell In[11], line 1
----> 1 df_xlsx = pd.read_excel('extras/aluguel.xlsx')
      2 df_xlsx
...
--> 144         raise ImportError(msg)
    145     else:
    146         return None

ImportError: Missing optional dependency 'openpyxl'.  Use pip or conda to install openpyxl.
1 resposta

Olá Ravi,

No final do erro está escrito que está faltando uma dependência para a leitura do arquivo excel no seu computador. Para resolver você deve abrir o terminal e executar o comando:

pip install openpyxl

Se quiser executar o comando no notebook basta adicionar o símbolo de exclamação na frente do pip.

!pip install openpyxl