Python Forum

Full Version: error using geoGen package from GITHUB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I am a newbie (a teacher trying to use python package for teaching CFD), I have been trying to us an open domain package "https://github.com/acrovato/geoGen/blob/master/wing.py" and have been running into error messages. I am using Python 3.6 (Anaconda and Spider), I have a suspicion that it cold be due to version difference and tried to use the tool :2to3" , but it did not solve the problem. I am attaching the code snipet and error message.

def read(self,fname):
        """Read data from file and stroe in matrix
        """
        _file = file(fname)
        label = _file.next().split(',')
        _file.close()
        data = np.loadtxt(fname, skiprows=1)
        return data 
error message is in
_file = file<name>
'file' is not found

Of course the required files are there
Apologies if it is stupid question ( I am a 68 year old FORTRAN coder)
Thanks in advance
Narahari
please post full traceback verbatim in error tags
Looking more into it - this python2 code
on line 136 they use file() function, which was depreciated in python3
change it to _file = open(fname)
There might be other problems though
Thank you Buran. As you predicted I have found a new error :
_file = open(fname)
label = _file.next().split(',')
AttributeError : '_io.TextIOWrapper object has no attribute 'next'

Can I use 'Futerize' command to fix similar errors ? I really dont want to go back to Python 2.7 version..
Regards
Narahari
the fix for this would be
label = next(_file).split(',')
I would suggest to try and use 2to3 tool.