2

So I am trying to use pyKML to create a KML file for google earth however when I try and import the module, I get the following:

 from pykml.factory import KML_ElementMaker as KML
Traceback (most recent call last):

  File "C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 2862, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-69-cdeb04502fb8>", line 1, in <module>
    from pykml.factory import KML_ElementMaker as KML

  File "C:\Anaconda\lib\site-packages\pykml\factory.py", line 216
    print write_python_script_for_kml_document(doc)
                                             ^
SyntaxError: invalid syntax

I tried to use simpleKML but it is not available for python 3.6

CodeMonkey
  • 22,825
  • 4
  • 35
  • 75

1 Answers1

3
print write_python_script_for_kml_document(doc)

is a line of code which works in Python 2, but doesn't in Python 3. As Python 3 requires parentheses:

print(write_python_script_for_kml_document(doc))

So I guess the library you are trying to use hasn't been adapted to Python 3. Or at least this version hasn't.

Grzegorz Oledzki
  • 23,614
  • 16
  • 68
  • 106
  • Shoot you're right, don't know why anaconda let me install it and all then when it wouldn't let me install simpleKML because it wasn't compatible. Maybe I will just have to revert to a former version of python. Oh well. No big loss. – Jordan Murray Nov 20 '17 at 21:59
  • Not sure how it works on Windows, but usually you are able to have multiple versions of Python installed on a single machine - incl. a Python 2 and a Python 3 one. – Grzegorz Oledzki Nov 20 '17 at 22:00
  • I'm certain I can have multiple versions of python installed, my only issue is how I would install the simpleKML or pyKML packages through the anaconda prompt with multiple instances of python installed. Guess that's my next mission! Thanks for the help. – Jordan Murray Nov 20 '17 at 22:05