Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Server Discussions

Find answers, ask questions, and share expertise about Alteryx Server.

Workflow Fails in Server... file path differences?

AlteryxUserFL
11 - Bolide

The below code is being run in an Alteryx Python tool. It works great when using designer on my desktop, but fails in the server. The error that is shown below is the one that happens after clicking run in the server. There is also a similar error shown when trying to upload to the server, but I could not copy that one.  Any ideas on the issues? Perhaps the server has a different file structure for downloads or something? 

 

 

import webbrowser
import time
import pandas as pd 
import os
from ayx import Alteryx
Download_Path = os.path.join(os.path.join(os.environ['USERPROFILE']) ) + "\Downloads\Test.csv"
webbrowser.open('Download Link To CSV, Link Hidden For Privacy')
time.sleep(15)
data = pd.read_csv(Download_Path) 
Alteryx.write(data,1)

 

 

Error When Running in Server:

  • --------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call last) <ipython-input-2-9926078606a5> in <module> 8 webbrowser.open(Download Link To CSV, Link Hidden For Privacy) 9 time.sleep(15) ---> 10 data = pd.read_csv(Download_Path) 11 Alteryx.write(data,1) 12 #os.remove(Download_Path) c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision) 700 skip_blank_lines=skip_blank_lines) 701 --> 702 return _read(filepath_or_buffer, kwds) 703 704 parser_f.__name__ = name c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds) 427 428 # Create the parser. --> 429 parser = TextFileReader(filepath_or_buffer, **kwds) 430 431 if chunksize or iterator: c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\pandas\io\parsers.py in __init__(self, f, engine, **kwds) 893 self.options['has_index_names'] = kwds['has_index_names'] 894 --> 895 self._make_engine(self.engine) 896 897 def close(self): c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine) 1120 def _make_engine(self, engine='c'): 1121 if engine == 'c': -> 1122 self._engine = CParserWrapper(self.f, **self.options) 1123 else: 1124 if engine == 'python': c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\pandas\io\parsers.py in __init__(self, src, **kwds) 1851 kwds['usecols'] = self.usecols 1852 -> 1853 self._reader = parsers.TextReader(src, **kwds) 1854 self.unnamed_cols = self._reader.unnamed_cols 1855 pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader.__cinit__() pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source() FileNotFoundError: [Errno 2] File b'C:\\Users\\svc-alteryx-dev\\Downloads\\Test.csv' does not exist: b'C:\\Users\\svc-alteryx-dev\\Downloads\\Test.csv' (Tool Id: 1)
5 REPLIES 5
BrianR
Alteryx
Alteryx

Looking at the python code, I believe you have touched on the issue with your last statement - "Perhaps the server has a different file structure for downloads or something?"

 

Instead of using the OS environment variable to call a User profile's local file, which runs fine on your desktop, when Alteryx Server sees that, it tries to resolve to that same location on the Server itself...and as a result, it's looking for the file called Test.csv, and it's looking for that file in the Server's C: drive..not your local desktop. 

 

Typically in situations like this, a good practice is to reference standard, UNC file location that both Alteryx Designer, as well as Alteryx Server can resolve. This could be a network share, for example, \\networksharedrive\foldername\test.csv. To make this work, your Server Run As Account will have to have access to that network share. If that's the case, Alteryx Server will be able to find and use that file in a workflow.

 

Offering a potential alternative for this example - it looks like that python code is simply requesting a particular file. You can reproduce this functionality with some of the Interface tools, namely, the File Browse tool. The dialog would present itself when running in Alteryx Server with a drop-down to browse for a file.

 

If that appeals to you, take a look at some of the Analytic Applications development materials - such as https://community.alteryx.com/t5/Videos/Alteryx-Platform-and-Introduction-to-Apps/td-p/66506 for an intro. 

AlteryxUserFL
11 - Bolide

Hello Brian, 

 

Thank you for your input.  Part of the python code calls to a link which auto downloads the CSV. Does an Alteryx server not have a download folder? The goal is for the flow to pull the CSV by opening the link, and then check the downloads folder for that CSV. I do not think using a network drive would help in this situation as I would still need to know the download path on the server to move the file to a network drive. 

 

Thank you,

Drew 

BrianR
Alteryx
Alteryx

The Server can utilize any local folder - provided that the same exact folder structure would exist from your desktop environment to your Server environment. From that python code, it looks like you are calling a user-specific file location, which resolves as the currently logged in user to that machine. This will work fine on your local desktop, but when the workflow runs on Server, it's going to use the account that the Alteryx Server runs as to resolve that file location, which according to the error, will look like C:\Users\svc-alteryx-dev\Downloads, and it will look for the file Test.csv there. That most likely is different than when you run on your local machine...on your local desktop, it will resolve to C:\Users\<your logged in user name>\Downloads. 

 

As a test, is it possible to create a fixed location on both your local machine where you build the workflow, and then on your Server, where you will be deploying the workflow - something like a folder directly off the C drive that will not use a variable name for the logged in user (C:\filedrop\ or something like that)?

 

AlteryxUserFL
11 - Bolide

Hello Brian, 

 

I can access a network drive location without issue. I think the issue is when this command is called, a csv is downloaded onto the server. The question is, where does Alteryx save downloads by default?  

 

webbrowser.open('Download Link To CSV, Link Hidden For Privacy')

 

BrianR
Alteryx
Alteryx

The location for Downloads will be based on the Windows user profile of the account set to work with Alteryx. I just tested this - on my system, it's using the Download folder tied to my Local System Account...however, in your case, it looks like the default location is listed in that error message - C:\Users\svc-alteryx-dev\Downloads\