Where to find PySide2 on MacOS?

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Where to find PySide2 on MacOS?

Post by keithsloan52 »

I am trying to run a script using FreeCAD in command line mode. The script uses Draft

The script starts

Code: Select all

import sys
# add folder containing FreeCAD.pyd, FreeCADGui.pyd to sys.path
#sys.path.append("C:/Program Files/FreeCAD 0.18/bin") # example for Windows
#sys.path.append("/usr/lib/freecad-daily/lib") # example for Linux
sys.path.append("/Applications/FreeCAD_0.19-C.app/Contents/Resources/lib") # example for MacOS
#sys.path.append("/usr/lib/freecad/lib") # example for Linux
try :
   import FreeCAD
except :
   print('The sys.path.append in gdml2step.py needs to be changed to find FreeCAD')
   exit()
import FreeCADGui
import Part
import Draft
import Import
But when I run it I get

Code: Select all

Traceback (most recent call last):
  File "gdml2step.py", line 14, in <module>
    import Draft
  File "/Applications/FreeCAD_0.19-C.app/Contents/Resources/Mod/Draft/Draft.py", line 53, in <module>
    from draftutils.utils import ARROW_TYPES as arrowtypes
  File "/Applications/FreeCAD_0.19-C.app/Contents/Resources/Mod/Draft/draftutils/utils.py", line 39, in <module>
    import PySide.QtCore as QtCore
  File "/Applications/FreeCAD_0.19-C.app/Contents/Resources/Ext/PySide/__init__.py", line 2, in <module>
    from PySide2 import __version__
ModuleNotFoundError: No module named 'PySide2'
On a Mac where would I find PySide2 so that I can add its location to path.

Thanks
mario52
Veteran
Posts: 4698
Joined: Wed May 16, 2012 2:13 pm

Re: Where to find PySide2 on MacOS?

Post by mario52 »

hi

use:

Code: Select all

import PySide2
from PySide2 import __version__
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Where to find PySide2 on MacOS?

Post by keithsloan52 »

mario52 wrote: Wed Oct 14, 2020 4:28 pm hi

use:

Code: Select all

import PySide2
from PySide2 import __version__
mario
Thanks for pointing me in the right direction

Actually

Code: Select all

import PySide2
print(PySide2.__file__)
Did the trick of finding it BUT it prints out

Code: Select all

/Applications/FreeCAD_0.19-C.app/Contents/Resources/lib/python3.8/site-packages/PySide2/__init__.py
and I already added

Code: Select all

/Applications/FreeCAD_0.19-C.app/Contents/Resources/lib
to sys.path

So now I don't know why I am getting the original error
mario52
Veteran
Posts: 4698
Joined: Wed May 16, 2012 2:13 pm

Re: Where to find PySide2 on MacOS?

Post by mario52 »

hi

I do not know ! sorry

mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
chrisb
Veteran
Posts: 54293
Joined: Tue Mar 17, 2015 9:14 am

Re: Where to find PySide2 on MacOS?

Post by chrisb »

keithsloan52 wrote: Wed Oct 14, 2020 3:04 am I am trying to run a script using FreeCAD in command line mode.
How do I run it on the Mac in commandline mode? I tried the code from Python console and it works (after adding an additional linefeed after the exit().
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Where to find PySide2 on MacOS?

Post by keithsloan52 »

chrisb wrote: Tue Oct 20, 2020 12:45 pm
keithsloan52 wrote: Wed Oct 14, 2020 3:04 am I am trying to run a script using FreeCAD in command line mode.
How do I run it on the Mac in commandline mode? I tried the code from Python console and it works (after adding an additional linefeed after the exit().
On my Mac on the first page of Launcher there is a group called Other, in this group is an App called Terminal.
First up terminal, then run from there
chrisb
Veteran
Posts: 54293
Joined: Tue Mar 17, 2015 9:14 am

Re: Where to find PySide2 on MacOS?

Post by chrisb »

keithsloan52 wrote: Tue Oct 20, 2020 5:11 pm On my Mac on the first page of Launcher there is a group called Other, in this group is an App called Terminal.
First up terminal, then run from there
Aah, I know the terminal well, I thought you started it without the GUI. I retried after starting from commandline and can still run the python code without issues.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
keithsloan52
Veteran
Posts: 2764
Joined: Mon Feb 27, 2012 5:31 pm

Re: Where to find PySide2 on MacOS?

Post by keithsloan52 »

Weird it now runs for me okay,

At one time it was not.
Post Reply