URL reading doensn't work in Python 3
mfournarakis opened this issue · 10 comments
Reading and writing the URL to fine does not work in python 3 because the file is in bytes
f.write((urlopen if 'http' in caffe_proto else open)(caffe_proto).read())
I tried using .decode('utf-8)
but there is conversion problem
Thanks for reporting! I’ll fix this. For now please download the proto file manually and use the local path explicitly.
I used the following to address it:
mybytes =urlopen(caffe_proto).read() mystr = mybytes.decode('ascii', 'ingore')
Of course, there are further issues given that python 3 doesn't support Unicode or long variables types anymore, but I just substituted the correct type.
What are long variables types?
I have this errors:
Traceback (most recent call last): File "caffemodel2pytorch.py", line 384, in <module> net_param.ParseFromString(open(args.model_caffemodel).read()) File "/usr/lib/python3.6/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa2 in position 2: invalid start byte
@mariosfourn I merged the @sebftw's PR that should fix this issue. Please let me know if it works for you now.
Traceback (most recent call last):
File "caffe2PytorchTry001.py", line 7, in
caffe_proto = 'https://raw.githubuserco
File "F:\Projects\VesselSupportClassify2
self.net_param = initialize(caffe_proto
File "F:\Projects\VesselSupportClassify2
subprocess.check_call(['protoc', '--pro
File "C:\Users\qjhs\AppData\Local\Program
retcode = call(*popenargs, **kwargs)
File "C:\Users\qjhs\AppData\Local\Program
with Popen(*popenargs, **kwargs) as p:
File "C:\Users\qjhs\AppData\Local\Program
restore_signals, start_new_session)
File "C:\Users\qjhs\AppData\Local\Program
startupinfo)
FileNotFoundError: [WinError 2] system cannot find out this file
not work on win10, python 3
@asa008 does your system have protoc (the protobuf compiler)?
@vadimkantorov I meet the same problem like @asa008, and have protoc with version 3.11. It still doesn't work on win10, python 3
Sorry, I don't even have the setup to work with this anymore. If you manage to debug it, please send a PR! If it's the problem with running protoc.exe
, you can probably print out the command line arguments, then debug just the process call in an isolated fashion. Then if you make it work, the rest would probably work too.