Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Don't forget to submit your entry for the Excellence Awards by October 30! | Need more information about the program? Check out the blog here
SOLVED

Python import library error

Highlighted
Alteryx Partner

Dear Alteryx Community,

 

I have a pyhton code that's run correctly from jupter.

However when I try to excute the code throw Python component it display the error

ModuleNotFoundError                       Traceback (most recent call last)

It's because I can't import the library 

import openpyxl

I tried  Package.installPackages(['openpyxl']) same error

 

My code is used to connect to an excel workbook and extract each sheet in new a workbook that work fine outside Alteryx.

 

 

import openpyxl
from openpyxl import load_workbook, Workbook
wb = openpyxl.load_workbook(r"My workbook") 
for sheet in wb.worksheets:
new_wb = Workbook()
ws = new_wb.active
for row_data in sheet.iter_rows():
for row_cell in row_data:
ws[row_cell.coordinate].value = row_cell.value
Racine=("My destination")
new_wb.save('{0}.xlsx'.format(Racine+sheet.title))

 

Many thanks in advance for help,

 

Regards,

Highlighted
12 - Quasar

I think you have to run Alteryx in Admin mode to import the Python libraries. Right click on the Alteryx icon and choose Run as administrator.

wwatson_0-1595070870001.png

 

Highlighted
Alteryx
Alteryx

Hi @messi007,

 

@wwatson is correct, you need to run Designer as admin when you run the 

Package.installPackages(['openpyxl']) 

command. After you run it as admin you should be able to use it in non-admin mode after.

 

 

Highlighted
Alteryx Partner

Hello,

 

Thanks @c-lopez and @wwatson  for the answers,

I succeeded to install the package 🙂 

 

Regards,

Labels