This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 69
Syntax error with python 3.6. Is there update to support Python 3 ? #90
Comments
boopathid
changed the title
Syntax error
Syntax error with python 3.6. Is there update to support Python 3 ?
Oct 18, 2019
Try running it with Python 2.x. It looks like the error message is
complaining about the syntax of the print statement:
print et.tostring(xml_schema_result, pretty_print=True)
Python 3.x requires parenthesis around the string to be printed so that
line in the nsxramlclient/client.py module would need to be modified for
compatibility.
There’s an issue filed for that here:
vmware-archive/nsxramlclient#20
…On Fri, Oct 18, 2019 at 4:49 PM Boopathi Duraisamy ***@***.***> wrote:
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}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#90>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABU7TTMDLV7KSGQUTDM3X5DQPIOM3ANCNFSM4JCMEEWQ>
.
|
I tried executing the playbook with python 2.7 & it worked fine. Below is how I passed the python2.7 via cli. |
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 :
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.
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}
The text was updated successfully, but these errors were encountered: