Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Syntax error with python 3.6. Is there update to support Python 3 ? #90

Open
boopathid opened this issue Oct 18, 2019 · 3 comments
Open

Comments

@boopathid
Copy link

Can you help why am i getting this error?

{"changed": false, "module_stderr": "Traceback (most recent call last):\n File "", line 114, in \n File "", line 106, in _ansiballz_main\n File "", line 49, in invoke_module\n File "/usr/lib64/python3.6/imp.py", line 235, in load_module\n return load_source(name, filename, file)\n File "/usr/lib64/python3.6/imp.py", line 170, in load_source\n module = _exec(spec, sys.modules[name])\n File "", line 618, in _exec\n File "", line 678, in exec_module\n File "", line 219, in _call_with_frames_removed\n File "/tmp/ansible_nsx_controllers_payload_dorq6873/main.py", line 195, in \n File "/tmp/ansible_nsx_controllers_payload_dorq6873/main.py", line 142, in main\n File "/venv/lib64/python3.6/site-packages/nsxramlclient/client.py", line 176\n print et.tostring(xml_schema_result, pretty_print=True)\n ^\nSyntaxError: invalid syntax\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

@boopathid boopathid changed the title Syntax error Syntax error with python 3.6. Is there update to support Python 3 ? Oct 18, 2019
@mamullen13316
Copy link

mamullen13316 commented Oct 19, 2019 via email

@boopathid
Copy link
Author

I tried executing the playbook with python 2.7 & it worked fine. Below is how I passed the python2.7 via cli.
-e ansible_python_interpreter=/venv27/bin/python

@linehammer
Copy link

If you write print() function in a program and someone using Python 2.x tries to run it, they will get an error. To avoid this, it is a good practice to import print function :

from __future__ import print_function

The from future import print_function ; to bring the print function from Python 3 into Python 2.x. Now your code works on both Python 2.x and Python 3.x . The future statements need to be near the top of the file because they change fundamental things about the language, and so the compiler needs to know about them from the beginning.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants