AnsweredAssumed Answered

Why does function with 2 parameters throw "myfunction() takes 1 positional argument but 2 were given"

Question asked by EternalDOOM on Jul 12, 2019
Latest reply on Jul 19, 2019 by LukeW



at the moment I'm testing python scripts in ArcGIS Pro, a very basic technique. But because ArcGIS Pro 2.3 works with python 3.6 in my case, I wanted to structure my code a bit more leveraging classes, modules, packages.


So my project structure is as follows:





import mypackage.process looks as follows, note without classes !!!


import arcpy

def run_process(param1, param2):
        arcpy.AddMessage(param1 + " " +param2)

in my I do

import mypackage.process as process

and then in my code I call run_process() method:

process.run_process('test', 'another test')

Now this runs perfectly if I start the script from my IDE. I pass two arguments to a function with two parameters BUT

once I call the script from within ArcGIS Pro -> Toolbox -> Script, I get the following error message:


TypeError: run_process() takes 1 positional argument but 2 were given


I can't get behind this error message and was researching on this problem a lot. Most occurences of such errors are related to method inside instances passing themself as additional first argument automatically but this shouln't be the case here. 


Moreover it tells me that my run_process() function would have only 1 parameter what is definetly not the case. The function takes 2 parameters!


Can someone please help me to reproduce this?