Showing results for 
Search instead for 
Did you mean: 

Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!

Python SDK - Object has no attribute message


Hi all!


I've tried to resolve this error, but I can't find it after looking a couple of times for at least 30 minutes ... so I'm reaching out. The second line of the code below seems to be throwing the error within the pi_init method:


root = Et.fromstring(str_xml)
self.str_file_path = root.find('browseFiles').text if root.find('browseFiles').text else ''


It wasn't hitting that error until I added the 'FileBrowse' 'alteryx-pluginwidget' from the 'Python - InputGui.html' sample posted to github. I was already using 'root' to pull other fields from the XML. The error message received is:


Error: FTPy - FTP with Python (3): Traceback (most recent call last):
  File "", line 47, in pi_init
AttributeError: 'NoneType' object has no attribute 'text'

Any ideas what I'm doing wrong? It's almost as if ... the 'FileBrowse' widget isn't ready to return text because the tool hasn't displayed yet. When I install the tool and drag it onto the canvas, the configuration area is blank, whereas before (without the 'FileBrowse' widget) the other fields were showing up in that panel.


If no one has ideas, I'm going to build the sample 'Input' tool and see if that one also has the issue described. If it doesn't ... I'll chew my boot, and then try again. :)


Hi @c2willis,


Thank you for posting on Alteryx Community.


In your code, it is assumed that root.find('browseFiles') always exists.


root.find('browseFiles').text if root.find('browseFiles').text else ''


Best scenario: 'browseFiles' exists and therefore root.find('browseFiles') exists and has a text attribute


BUT: what if 'browseFiles' could not be found? In this case root.find('browseFiles') is null (None in Python) and therefore doesn't have a text attribute.


I would suggest to use the following instead:


root.find('browseFiles').text if 'browseFiles' in str_xml else ''

The previous will ensure that 'browseFiles' is actually part of the GUI (str_xml) before reaching out to its text attribute.


Hope this helps,


Paul Noirel

Sr Customer Support Engineer, Alteryx




Thanks @PaulN!


I think that was partially it, but not sure why browseFiles was not part of the str_xml ... it should have been!!


However, since changing this line did not solve the issues I was having with my tool, I tried just the basic Input tool from github and it worked. Scratching my head I went back to my tool and tried removing the pluginwidget field in favor of a simple text box. I got further with that modfication but it seems that the html form is not loading completely into the configuration side-panel. It shows the headings and labels but not the fields used to enter the values.


I'll attach my .yxi file (Edit: won't let me attach any files *sigh*) in case someone has time and/or iclination to review what I've done. I'm typing lame today - RSI :) - so I might take a break for a while. Seems my GUI interface is messed up ...


In the tool, I'm trying to create a simple Input and Output tool that only outputs the file path of the newly created output .txt file. The input to the tool is a python ftp connection to mainframe file system to GET a file. I plan to expand on the functionality in the future, hence python instead of the 'Run Command' developer tool (among other considerations).




Turns out ... my problem was a HTML GUI SDK issue that was causing a further issue when the html was passed to python as the str_xml variable.


I had copied one of the python SDK samples and updated it with extra fields, and for some reason the single <link> import was not enough, I needed to have a second <link> import to allow the fields I was using in my html file show up:


document.write('<link rel="import" href="' + window.Alteryx.LibDir + '1/lib/alteryx/gui/includes.html">');
document.write('<link rel="import" href="' + window.Alteryx.LibDir + '2/lib/includes.html">');

I'll go read the HTML GUI SDK some more to see what is going on there, but at least initially (at this point) I'm confused why the field elements are in 2 separate 'includes.html' files.



Two more items I noticed:

  1. With the above 2 'includes.html' files, the <lengend> tags were not styled correctly, while the other tagged elements were styled correctly.
  2. Reimporting the same tool moves the 'tool category' (e.g. Laboratory) out of the pinned categories section of the category tool bar.

At least I was able to progress past the error, test my python tool, and get it to do what I was intended it to do. And no more RSI! Win Win!

Sr. Community Content Manager
Sr. Community Content Manager

I believe

document.write('<link rel="import" href="' + window.Alteryx.LibDir + '2/lib/includes.html">');

is for v2 of the GUI SDK whereas

document.write('<link rel="import" href="' + window.Alteryx.LibDir + '1/lib/alteryx/gui/includes.html">');

is for v1.


You should probably stick to one or the other (preferably the current - v2). Deleting the v1 import may resolve your styling issues.


Thanks @NeilR!


I wondered if that was the case, but didn't have time today to go read the V2 documentation to see what was causing the issue in my html file. I will check it out though, and I imagine it's as simple as updated <ayx ...> tags or attribute labels in the tags. I 'knew' it would be something simple that I was missing ... :)


@NeilR and @PaulN --


It appears the <alteryx-pluginwidget> tags were deprecated and replaced with <ayx> tags ... which is fine. Although, I couldn't find mention of that in the HTML SDK, and the zip file I downloaded at the end of June still has them in the samples.


Bigger question, it also appears that the FileBrowse widget is also no longer supported, at least I can't find mention of it in the current HTML SDK documentation or the API documentation. For applications where we want users to browse to a directory and select a file, we would need to place our custom Python tool inside a Macro or App to utilize the File/Folder Browse Interface tools. Does that about summarize it?


I guess I could use JS to open a file browse window, is that available from the Alteryx tool? Do you know of others doing this?


Hey @c2willis,


You are correct: there are still lots of examples based on v1 of HTML SDK around.


FileBrowse is not a documented widget. That said, the following should work:


To select a file:


<ayx data-ui-props="{type: 'FileBrowse', browseType: 'File'}" data-item-props="{dataName: 'selected_file'}"></ayx>

To select a folder:


<ayx data-ui-props="{type: 'FileBrowse', browseType: 'Folder'}" data-item-props="{dataName: 'selected_folder'}"></ayx>




Paul Noirel

Sr Customer Support Engineer, Alteryx



Thanks @PaulN! I'll try that out soon. Was too busy today to try it :)


Ok, had time at end of the day to look at this again.


Weirdly, even after removing the v1 includes.html, it was not creating the FileBrowse correctly under 2018.1. So I decided to bite the bullet and update to 2018.2, which I'd been meaning to do anyway, and it works under 2018.2!


So it's looking spiffy now, got check boxes and stuff all looking nice!


Next on my bug list is the password field which I see some others have been having some trouble with too, but I'll save that for next week.