molmod / QuickFF

A Python code to quickly derive ab initio parameterized force fields.
GNU General Public License v3.0
38 stars 15 forks source link

coercing to Unicode: need string or buffer, PosixPath found #18

Open ignaspakamore opened 4 years ago

ignaspakamore commented 4 years ago

Hi, when trying to set settings in jupyter notebook: settings = Settings(fn_yaff='pars_cov.txt', plot_traj='All', xyz_traj=True) The following error occurred:


TypeError Traceback (most recent call last)

in () ----> 1 settings = Settings(fn_yaff='pars_cov.txt', plot_traj='All', xyz_traj=True) /Users/ignaspakamore/Anaconda/anaconda2/lib/python2.7/site-packages/quickff/settings.py in __init__(self, fn, **kwargs) 166 #first read general RC settings from .quickffrc file 167 with path('quickff.data', 'quickffrc') as fn_default: --> 168 self.read_config_file(fn_default) 169 #if a config file is provided, read settings from this file and 170 #overwrite the default RC settings /Users/ignaspakamore/Anaconda/anaconda2/lib/python2.7/site-packages/quickff/settings.py in read_config_file(self, fn) 190 191 def read_config_file(self, fn): --> 192 with open(fn, 'r') as f: 193 for iline, line in enumerate(f.readlines()): 194 line = line.split('#')[0].lstrip().rstrip().rstrip('\n') TypeError: coercing to Unicode: need string or buffer, PosixPath found
lvduyfhu commented 4 years ago

Dear ignaspakamore,

first of all, thank you for reporting this and sorry for the late reply. This might have to do with compatibility between python 3 and python 2. If this still is an issue, maybe the following small hack in the source code of QuickFF could work.

In the line 168 of settings.py mentioned in the second paragraph of your traceback, change the line self.read_config_file(fn_default)

to the line self.read_config_file(str(fn_default))

and reinstall QuickFF.

cheers, Louis