Alteryx Designer Desktop Discussions

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

The python tool not allowing other users to import packages & wont work on server

Benjaminlasker
Alteryx
Alteryx

Hi All. I am having a lot of issues with the python tool with Alteryx Designer. The workflow which I posted below is an analytic app that is grabbing an excel sheet from the users files to run through the workflow. The python tool reads the data in through "#1" and exports a formatted PowerPoint file that incorporates the data that was in the excel sheet. The workflow works perfect on my computer when run as an analytic app or just on desktop itself. However, when I share this app with other co workers, they get this error:

c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\ayx\Package.py in installPackages(package, install_type, debug)

    200     print(pip_install_result["msg"])

    201     if not pip_install_result["success"]:

--> 202         raise pip_install_result["err"]

c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\ayx\Utils.py in runSubprocess(args_list, debug)

    118

    119     try:

--> 120         result = subprocess.check_output(args_list, stderr=subprocess.STDOUT)

    121         if debug:

    122             print("[Subprocess success!]")

c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\subprocess.py in check_output(timeout, *popenargs, **kwargs)

    409         kwargs['input'] = '' if kwargs.get('universal_newlines', False) else b''

    410

--> 411     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,

    412                **kwargs).stdout

    413

c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\subprocess.py in run(input, capture_output, timeout, check, *popenargs, **kwargs)

    510         retcode = process.poll()

    511         if check and retcode:

--> 512             raise CalledProcessError(retcode, process.args,

    513                                      output=stdout, stderr=stderr)

    514     return CompletedProcess(process.args, retcode, stdout, stderr)

CalledProcessError: Command '['c:\\program files\\alteryx\\bin\\miniconda3\\envs\\designerbasetools_venv\\python.exe', '-I', '-m', 'pip', 'install', 'python-pptx']' returned non-zero exit status 1.

 

Python (67): ---------------------------------------------------------------------------

ModuleNotFoundError                       Traceback (most recent call last)

<ipython-input-2-796bacf0a30c> in <module>

      1 import pandas as pd

      2 import numpy as np

----> 3 from pptx.util import Inches, Pt

      4 import pandas as pd

      5 import math

ModuleNotFoundError: No module named 'pptx'

 

Python (67): ---------------------------------------------------------------------------

NameError                                 Traceback (most recent call last)

<ipython-input-5-7f368c67b3ff> in <module>

      7 subset_data = data.head(num_use_cases_to_display)

      8

----> 9 slide1 = pr1.slides.add_slide(pr1.slide_layouts[8])

     10 placeholders = slide1.placeholders

     11

NameError: name 'pr1' is not defined


The PR1 is a template is being stored in a public s3 bucket which allows any user to access the formatted template in which the data gets entered in. It works fine on my computer as mentioned above but whenever someone else try's it on their computer they get this error above.  Additionally I built this workflow initially on ADMIN in order for the python packages to install however I am able to run it just fine without using ADMIN.

My other problem is when I try to upload / save this workflow to server. It will fail uploading because of this error: (NameError: Name 'data' is not defined). When trying to publish it to server it doesn't recognize the that the python tool is reading the data as "#1". I attached a screenshot of the code I use that recognizes the data as #1 on my local machine but not when I try to puplish it to server it gives me that error above.

 

 

3 REPLIES 3
gawa
15 - Aurora
15 - Aurora

hi @Benjaminlasker 

 

When you share the workflow containing external library in Python tool, the other users have to run workflow as an ADMIN at first so that the necessary libraries are installed on their computers. After then, workflow can be executed.

This is also the case when you publish workflow to Alteryx Server. If you want to run this workflow on Server, first login to the computer where Server is running, and install the necessary Python libraries by executing workflow with Alteryx Designer in that computer.

 

For 2nd question, error when upload to server, I faced the same issue. My workaround is to uncheck "Validate Workflow" option, and bypass the validation process. Doing so allows me to upload workflow containing Python tools successfully, and of course run properly on Server.

Benjaminlasker
Alteryx
Alteryx

Hi @gawa thank you so much for your response and help!! Regarding the ADMIN issue that makes sense, thank you for that insight I will make that known when new users run the workflow.  Regarding the Server issue I am still unable to run it in server unfortunately even after trying your work around. I am getting this error:

- FileNotFoundError Traceback (most recent call last) c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\opc\serialized.py in _write(self) 80 with _PhysPkgWriter.factory(self._pkg_file) as phys_writer: ---> 81 self._write_content_types_stream(phys_writer) 82 self._write_pkg_rels(phys_writer) c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\opc\serialized.py in _write_content_types_stream(self, phys_writer) 90 """ ---> 91 phys_writer.write( 92 CONTENT_TYPES_URI, c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\opc\serialized.py in write(self, pack_uri, blob) 219 """Write `blob` to zip package with membername corresponding to `pack_uri`.""" --> 220 self._zipf.writestr(pack_uri.membername, blob) 221 c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\util.py in __get__(self, obj, type) 214 # ---__dict__ value of same name ('fget' nominally) --> 215 value = self._fget(obj) 216 obj.__dict__[self.__name__] = value c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\opc\serialized.py in _zipf(self) 224 """`ZipFile` instance open for writing.""" --> 225 return zipfile.ZipFile(self._pkg_file, "w", compression=zipfile.ZIP_DEFLATED) 226 c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\zipfile.py in __init__(self, file, mode, compression, allowZip64, compresslevel, strict_timestamps) 1250 try: -> 1251 self.fp = io.open(file, filemode) 1252 except OSError: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\WINDOWS\\system32\\config\\systemprofile\\Downloads\\Value Captured through Alteryx.pptx' During handling of the above exception, another exception occurred: FileNotFoundError Traceback (most recent call last) <ipython-input-5-7f368c67b3ff> in <module> 238 path = os.path.expanduser('~\Downloads') 239 print(path) --> 240 pr1.save(path+"\Value Captured through Alteryx.pptx") c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\presentation.py in save(self, file) 37 to a file (a string) or a file-like object. 38 """ ---> 39 self.part.save(file) 40 41 @property c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\parts\presentation.py in save(self, path_or_stream) 105 file-like object. 106 """ --> 107 self.package.save(path_or_stream) 108 109 def slide_id(self, slide_part): c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\opc\package.py in save(self, pkg_file) 151 `file` can be either a path to a file (a string) or a file-like object. 152 """ --> 153 PackageWriter.write(pkg_file, self._rels, tuple(self.iter_parts())) 154 155 def _load(self): c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\opc\serialized.py in write(cls, pkg_file, pkg_rels, parts) 74 relationships. 75 """ ---> 76 cls(pkg_file, pkg_rels, parts)._write() 77 78 def _write(self): c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\opc\serialized.py in _write(self) 81 self._write_content_types_stream(phys_writer) 82 self._write_pkg_rels(phys_writer) ---> 83 self._write_parts(phys_writer) 84 85 def _write_content_types_stream(self, phys_writer): c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\opc\serialized.py in __exit__(self, exc_type, exc_value, exc_traceback) 214 using. 215 """ --> 216 self._zipf.close() 217 218 def write(self, pack_uri, blob): c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\util.py in __get__(self, obj, type) 213 # ---and store that value in the (otherwise unused) host-object 214 # ---__dict__ value of same name ('fget' nominally) --> 215 value = self._fget(obj) 216 obj.__dict__[self.__name__] = value 217 return value c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\site-packages\pptx\opc\serialized.py in _zipf(self) 223 def _zipf(self): 224 """`ZipFile` instance open for writing.""" --> 225 return zipfile.ZipFile(self._pkg_file, "w", compression=zipfile.ZIP_DEFLATED) 226 227 c:\program files\alteryx\bin\miniconda3\envs\designerbasetools_venv\lib\zipfile.py in __init__(self, file, mode, compression, allowZip64, compresslevel, strict_timestamps) 1249 while True: 1250 try: -> 1251 self.fp = io.open(file, filemode) 1252 except OSError: 1253 if filemode in modeDict: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\WINDOWS\\system32\\config\\systemprofile\\Downloads\\Value Captured through Alteryx.pptx' (ToolId: 67)

My python tool includes code that grabs a PowerPoint template from an S3 bucket and then puts data from the uploaded excel file in specific placeholders and then exports the data to the users download section in their files through this code: 
path = os.path.expanduser('~\Downloads')
print(path)
pr1.save(path+"\Value Captured through Alteryx.pptx")

 

I believe this is the issue however do not know how to fix that so that it will download/export a pptx file for the user.

Thank you in advance for your help

danilang
19 - Altair
19 - Altair

Hi @Benjaminlasker 

 

Judging from this line

No such file or directory: 'C:\\WINDOWS\\system32\\config\\systemprofile\\Downloads\\Value Captured through Alteryx.pptx' (ToolId: 67)

I'd say that your Alteryx server is configured to run workflows using Local System as opposed to a named user.  It's the only way that 

path = os.path.expanduser('~\Downloads') can expand to C:\WINDOWS\system32\config\systemprofile\Downloads as opposed to c:\users\{username}\Downloads

 

One way to get around this is use [Engine.WorkflowDirectory]+"\downloads" to build a path that the workflow will always have access to.  Pass the evaluated string into your python tool and use this as download directory.   On desktop, this will give you \current dir\downloads.  On the server it will evaluate to  E:\ProgramData\Alteryx\Service\Staging\{guid}\downloads

 

Dan

Labels