geoclaw
geoclaw copied to clipboard
potential issue with syntax in GDAL
I'm currently trying to get some GeoClaw results up and running in Google Earth but am running into what I think are some Python 3.7 incompatibilities. When following the documented workflow (here: http://www.clawpack.org/googleearth_plotting.html), I get this error when testing the instalation of GDAL:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/smmorey/anaconda3/share/gdal/gdal_test.py", line 79, in <module>
docfile.write(etree.tostring(etree.ElementTree(doc),pretty_print=True))
TypeError: write() argument must be str, not bytes
This is referencing the gdal_test.py file I downloaded from the above link. I'm pretty sure this is just a change in syntax python updates, but I'm can't figure out how to update this line appropriately.
This doesn't seem to be the biggest issue, as GDAL seems optional, but I thought I'd bring it up anyway.
I have seen this come up in other contexts as well, mostly plotting though. I think it may actually be a change in matplotlib
though. Definitely deserves some attention to what is really going on though. @ donnacalhoun have you run into this yet?
Thanks for catching this. I am updating the test now, but here is a quick fix you can try :
Change line 79 to add a “decode()” statement.
docfile.write(etree.tostring(etree.ElementTree(doc),pretty_print=True).decode())
Can you let me know whether this works or not?
Thanks,
Donna
Donna Calhoun Associate Professor Department of Mathematics, Mathematics Bldg 241A Boise State University 1910 University Drive Boise, ID 83725-1555 (208) 426-3386 http://math.boisestate.edu/~calhoun
On Oct 16, 2019, at 3:35 PM, susannah [email protected] wrote:
I'm currently trying to get some GeoClaw results up and running in Google Earth but am running into what I think are some Python 3.7 incompatibilities. When following the documented workflow (here: http://www.clawpack.org/googleearth_plotting.html http://www.clawpack.org/googleearth_plotting.html), I get this error when testing the instalation of GDAL:
Traceback (most recent call last): File "
", line 1, in File "/home/smmorey/anaconda3/share/gdal/gdal_test.py", line 79, in docfile.write(etree.tostring(etree.ElementTree(doc),pretty_print=True)) TypeError: write() argument must be str, not bytes This is referencing the gdal_test.py file I downloaded from the above link. I'm pretty sure this is just a change in syntax python updates, but I'm can't figure out how to update this line appropriately. This doesn't seem to be the biggest issue, as GDAL seems optional, but I thought I'd bring it up anyway.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/clawpack/geoclaw/issues/408?email_source=notifications&email_token=AAKXMQNLUG4UBWYUKTWVIXDQO6CI3A5CNFSM4JBRK5RKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HSJFRLA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKXMQN46XWQ4D6DBRO26ADQO6CI3ANCNFSM4JBRK5RA.
That worked! Thanks, Donna!
Thanks for confirming that.
You probably had to make other changes to the gdal_test.py example (e.g. the print statement).
Did you have to make any more substantial changes?
Thanks again,
Donna
Donna Calhoun Associate Professor Department of Mathematics, Mathematics Bldg 241A Boise State University 1910 University Drive Boise, ID 83725-1555 (208) 426-3386 http://math.boisestate.edu/~calhoun
On Oct 16, 2019, at 3:57 PM, susannah [email protected] wrote:
That worked! Thanks, Donna!
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/clawpack/geoclaw/issues/408?email_source=notifications&email_token=AAKXMQO7PLZDUNBAO2SMI7DQO6E3HA5CNFSM4JBRK5RKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBOCASI#issuecomment-542908489, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKXMQLJOQYOO6VTXAYMSDLQO6E3HANCNFSM4JBRK5RA.
Does this work across versions of Python?
Not sure about that, but I know that it was required when converting to Python 3.x
I can try it in Python 2.x, once I get my version of gdal working.
Donna Calhoun Associate Professor Department of Mathematics, Mathematics Bldg 241A Boise State University 1910 University Drive Boise, ID 83725-1555 (208) 426-3386 http://math.boisestate.edu/~calhoun
On Oct 16, 2019, at 4:02 PM, Kyle Mandli [email protected] wrote:
Does this work across versions of Python?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/clawpack/geoclaw/issues/408?email_source=notifications&email_token=AAKXMQPCP3MKHVMJCQVKRPDQO6FQHA5CNFSM4JBRK5RKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBOCO6Q#issuecomment-542910330, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKXMQP7GCF6VNY7J3NMWZLQO6FQHANCNFSM4JBRK5RA.
I had to change the print statements in gdal_test.py and also a couple of print statements in factory.py within pykml, but nothing major besides that.
It ran fine for me without the updated line in Python 2.7.
Right - the updated line wasn’t needed in Python 2.7. But does the updated line work in 2.7? (I think it should; the .decode() statement was probably just assumed in 2.7)
Donna Calhoun Associate Professor Department of Mathematics, Mathematics Bldg 241A Boise State University 1910 University Drive Boise, ID 83725-1555 (208) 426-3386 http://math.boisestate.edu/~calhoun
On Oct 16, 2019, at 4:06 PM, susannah [email protected] wrote:
It ran fine for me without the updated line in Python 2.7.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/clawpack/geoclaw/issues/408?email_source=notifications&email_token=AAKXMQPLHFKIIA2KFTWAWGTQO6F6DA5CNFSM4JBRK5RKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBOCXWA#issuecomment-542911448, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKXMQMUOC2QBNTGHZ34SCTQO6F6DANCNFSM4JBRK5RA.
I am not sure but I think your assumption is probably correct. At the very least we should test this and if there is a difference then fence it off with a check on the version of Python if need be.