xlsxwriter

Issue #40 resolved
Robert Wagner created an issue

I installed the xlsxwriter via pip3, however at runtime I am getting an error: ModuleNotFoundError: No module named 'xlsxwriter'

Is their a path issue? if so , suggestions are welcome :) Just a rookie trying to get things going in the python world in my shop.

from xlsxwriter import Workbook
import ibm_db_dbi as db2
conn = db2.connect()
cur = conn.cursor()
cur.execute("select * from dtalib.customer")
headers = [descr[0] for descr in cur.description]

with Workbook('customer.xlsx') as workbook:
     worksheet = workbook.add_worksheet()
     worksheet.write_row('A1', headers)
     for rownum, row in enumerate(cur, start=1):
         worksheet.write_row(rownum, 0, row)

Comments (7)

  1. Kevin Adler

    Yeah, probably a PATH issue. Make sure you have /QOpenSys/pkgs/bin at the front of $PATH:

    PATH=/QOpenSys/pkgs/bin:$PATH
    export PATH
    

    If you just installed Python 3 via yum, you might also need to run hash -r to clear bash's lookup cache.

    Also, make sure to start Python with the python3 command, not python.

  2. Robert Wagner reporter

    I am using eclipse , and do not seem to be having luck with changing the path. Also when tried from the green screen I get a different error. I will upload all items. profile path.JPGprofile path error on green screen.JPGProfile path issue on eclipse.JPG

  3. Kevin Adler

    ^M is a carriage return. You'll need to change the file to *LF endings in order for it to work in PASE.

    The Eclipse problem is that it is trying to execute on your Windows system. if that's what you want, you'll need to install xlsxwriter there instead of on the IBM i. I also noticed that you're using the 32-bit version of Python on Windows. I'd recommend using 64-bit Python instead.

  4. Jesse G

    I believe this has been resolved as an issue with newline characters. Please reopen or open a new issue if there is a remaining issue. Thanks!

  5. Log in to comment