my python version?

Need help, or want to share a macro? Post here!
mrrclb48z
Posts: 27
Joined: Wed Feb 07, 2018 11:20 am

my python version?

Postby mrrclb48z » Wed May 02, 2018 6:53 am

my python version?
full script :

Code: Select all

import sys
print "123"         #out:Report view
print sys.version
Gui.doCommand("print(sys.version)")
Gui.doCommand("sys.version")
Gui.doCommand(sys.version)

#Traceback (most recent call last): File "C:/xxxx/MyPythonVersion.FCMacro", 
#line 4, in Gui.doCommand("print(sys.version)") File "", 
#line 1, in : name 'sys' is not defined 
wandererfan
Posts: 2355
Joined: Tue Nov 06, 2012 5:42 pm

Re: my python version?

Postby wandererfan » Wed May 02, 2018 1:02 pm

mrrclb48z wrote:
Wed May 02, 2018 6:53 am
my python version?
try this:

Code: Select all

import sys
print "123"         #out:Report view
print sys.version
Gui.doCommand("import sys")      # add this
Gui.doCommand("print(sys.version)")
Gui.doCommand("sys.version")
Gui.doCommand(sys.version)        # this won't work
mrrclb48z
Posts: 27
Joined: Wed Feb 07, 2018 11:20 am

Re: my python version?

Postby mrrclb48z » Mon May 07, 2018 4:04 pm

Thank you.

try this:
Python Console----------------------------------------------------------------------------
>>> import sys
>>> print(sys.version)
>>> sys.version
>>> 2.7.8 (default, Nov 17 2014, 20:37:05) [MSC v.1800 64 bit (AMD64)]
>>>

Report view-------------------------------------------------------------------------------
123
2.7.8 (default, Nov 17 2014, 20:37:05) [MSC v.1800 64 bit (AMD64)]
2.7.8 (default, Nov 17 2014, 20:37:05) [MSC v.1800 64 bit (AMD64)]
Traceback (most recent call last):
File "C:/Users/xxxx/FreeCAD/000MyPythonVersion.FCMacro", line 7, in <module>
Gui.doCommand(sys.version) # this won't work
<type 'exceptions.SyntaxError'>: ('invalid syntax', ('<string>', 1, 5, '2.7.8 (default, Nov 17 2014, 20:37:05) [MSC v.1800 64 bit (AMD64)]\n'))


full script :

Code: Select all

import sys
Gui.doCommand(sys.version)
Report view----------------------------------------------------------------------------------
Traceback (most recent call last):
File "C:/Users/xxx/FreeCAD/000MyPythonVersion.FCMacro", line 2, in <module>
Gui.doCommand(sys.version)
<type 'exceptions.SyntaxError'>: ('invalid syntax', ('<string>', 1, 5, '2.7.8
(default, Nov 17 2014, 20:37:05) [MSC v.1800 64 bit (AMD64)]\n'))
Python console--------------------------------------------------------------------------------
>>> 2.7.8 (default, Nov 17 2014, 20:37:05) [MSC v.1800 64 bit (AMD64)]

how to ?(not display report view)(python console ok)