Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

ModuleNotFoundError while opening password protected file in alteryx using python tool

saachitalwar
8 - Asteroid

Hi,

I have a process for which I need to use a password protected file. I have tried using the python tool to unlock the file but it keeps giving me package errors. the msoffcrypto and openpyxl packages aren't being installed. I don't have admin access so can't run as an administrator to install them either.

 

Code:

 

from ayx import Alteryx


import pandas as pd
import io
import msoffcrypto
import os
import openpyxl

df = Alteryx.read('#1')

protected_excel_filepath = df.iloc[0,0]

if os.path.exists(protected_excel_filepath):
unprotected_excel_content = io.BytesIO()
with open(protected_excel_filepath, 'rb') as f:
msoffcryptoobj = msoffcrypto.OfficeFile(f)
msoffcryptoobj.load_key(password="abc123")
unprotected_excel_content = io.BytesIO()
msoffcryptoobj.decrypt(unprotected_excel_content)

df= pd.read_excel(unprotected_excel_content,engine = "openpyxl")


Alteryx.write(df,2)

 

1 REPLY 1
apathetichell
20 - Arcturus

You have to run Alteryx as admin  (not install the admin version)- if not - you'll have to install the packages via CLI in your Python venv.

 

also - you'll need to have the install.packages command for your non-standard packages.

Labels
Top Solution Authors