[Python] Export dataframe in pyspark to excel file given the 'openpyxl' module is not installed

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to write my spark dataframes in an excel file to generate desired reports by changing them in pandas dataframe and then using

    panda_df = df.toPandas()
    writer = pd.ExcelWriter(filename)
    panda_df.to_excel(writer,'Sheet1', startcol = 0, startrow = 0)


    this gives an error saying

    File "/usr/lib64/python2.6/site-packages/pandas/io/excel.py", line 350, in __init__
    from openpyxl.workbook import Workbook
    ImportError: No module named openpyxl.workbook


    I am running this on a remote server and hence do not have admin rights to use sudo apt-get as it says "Sudo: apt-get: command not found" and I have also tried using pip to no usage as it is not installed either. Is there any other way I can write my dataframes in excel?

    Continue reading...

Compartilhe esta Página