bacnet_scan output a csv file error TypeError: a bytes-like object is required, not 'str'

左心房为你撑大大i 提交于 2020-12-15 01:35:25

问题


When running bacnet_scan.py it looks like this:

(volttron) (base) bartlino@bartlino-Latitude-E5530-non-vPro:~/Desktop/volttron/scripts/bacnet$ python bacnet_scan.py

Device Address        = <Address 192.168.0.190>
Device Id             = 0
maxAPDULengthAccepted = 1476
segmentationSupported = noSegmentation
vendorID              = 245

Device Address        = <Address 192.168.0.102>
Device Id             = 3056183
maxAPDULengthAccepted = 1024
segmentationSupported = segmentedBoth
vendorID              = 842

Device Address        = <RemoteStation 12345:2>
Device Id             = 201201
maxAPDULengthAccepted = 286
segmentationSupported = noSegmentation
vendorID              = 11

Trying to add on a csv file output with python bacnet_scan.py --csv-out ~/Desktop/volttron/configs/test_mult.csv

I get an error:

Traceback (most recent call last):
  File "bacnet_scan.py", line 203, in <module>
    this_csv_file.writeheader()
  File "/home/bartlino/anaconda3/lib/python3.8/csv.py", line 143, in writeheader
    return self.writerow(header)
  File "/home/bartlino/anaconda3/lib/python3.8/csv.py", line 154, in writerow
    return self.writer.writerow(self._dict_to_list(rowdict))
TypeError: a bytes-like object is required, not 'str'

Any tips?


回答1:


If you are not working out of the latest development branch, I'd suggest trying that first, as there was a PR accepted after the 8.0 release that fixed an issue related to bytes vs string in the output of this script. I'm also not certain how they'd interact, but you appear to have 2 virtual environments activated currently, and its possible that's messing with some versioning... Since its Python3.8 for your Anaconda, I'm doubtful of that, but its something to consider.



来源:https://stackoverflow.com/questions/65241559/bacnet-scan-output-a-csv-file-error-typeerror-a-bytes-like-object-is-required

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!