Problems with path and Python 3.6

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Manja
Posts: 49
Joined: Tue Apr 03, 2018 6:35 am

Problems with path and Python 3.6

Post by Manja »

Hello
In the ./Mod/Path/PathScripts/PathGuiInit.py module
and ./Mod/Path/InitGui.py look for
capture_output . The Python version 3.6 of SuSE Leap 15.3 does not have a subprocess capture_output.
Please change from:

Code: Select all

                 r = subprocess.run(
                     ["camotics", "--version"], capture_output=True, text=True
in:

Code: Select all

                 r = subprocess.run(
                     ["camotics", "--version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE
then it also works with Python 3.6

Code: Select all

OS: openSUSE Leap 15.3 (KDE//usr/share/xsessions/plasma5)
Word size of FreeCAD: 64-bit
Version: 0.21.29388 (Git)
Build type: Release
Branch: master
Hash: a88f69a9f0353955d9e94b78d88eeebf6567a685
Python 3.6.15, Qt 5.12.7, Coin 3.1.3, Vtk 8.2.0, OCC 7.5.0
Locale: German/Germany (de_DE)
Installed mods: 
  * FCGear
  * BOLTSFC
  * fasteners
  * A2plus 0.4.54b
  * fcgear 1.0.0
  * Geomatics
Last edited by Kunda1 on Sun Jul 17, 2022 1:33 pm, edited 1 time in total.
Reason: added code tags for clarity
with kind regards, Berthold

Linux SuSE leap 15.3 , 64Bit
wmayer
Founder
Posts: 18819
Joined: Thu Feb 19, 2009 10:32 am

Re: Problems with path and Python 3.6

Post by wmayer »

The Python version 3.6 of SuSE Leap 15.3 does not have a subprocess capture_output.
@sliptonic

Here another issue I have encountered:
With git commit e428337ffcdb the packaging package is used now but on Windows and some Linux systems FreeCAD will fail to load the Path wb. Luckily even for Py3.6 there is the package available python3-packaging. I guess other Linux distributions offer similar packages.

For Windows users who don't have that package can e.g. download http://archive.ubuntu.com/ubuntu/pool/m ... rig.tar.gz and put the sub-directory package into the site-packages directory of a FreeCAD installation.
agren
Posts: 33
Joined: Sat Apr 20, 2019 7:37 am

Re: Problems with path and Python 3.6

Post by agren »

wmayer wrote: Sat Jul 02, 2022 9:08 am ...
With git commit e428337ffcdb the packaging package is used now but on Windows and some Linux systems FreeCAD will fail to load the Path wb
...
My suggestion to use packaging.Version. An alternative is distutils.version but that's scheduled for removal in Python 3.12.
If we don't want to add a dependency on packaging or another third party library I can implement a simple version handling module.
wmayer
Founder
Posts: 18819
Joined: Thu Feb 19, 2009 10:32 am

Re: Problems with path and Python 3.6

Post by wmayer »

agren wrote: Sat Jul 02, 2022 1:45 pm My suggestion to use packaging.Version. An alternative is distutils.version but that's scheduled for removal in Python 3.12.
We shouldn't do this.
If we don't want to add a dependency on packaging or another third party library I can implement a simple version handling module.
The package is completely written in Python and thus it's not a big issue to use it. So, no need to write something on our own.

I only brought up this topic to make package maintainers (on Linux systems) aware to add a dependency. And on Windows future LibPack versions or installers should add this package, too.
User avatar
sliptonic
Veteran
Posts: 2966
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Problems with path and Python 3.6

Post by sliptonic »

wmayer wrote: Sat Jul 02, 2022 9:08 am @sliptonic

Here another issue I have encountered:
With git commit e428337ffcdb the packaging package is used now but on Windows and some Linux systems FreeCAD will fail to load the Path wb. Luckily even for Py3.6 there is the package available python3-packaging. I guess other Linux distributions offer similar packages.

For Windows users who don't have that package can e.g. download http://archive.ubuntu.com/ubuntu/pool/m ... rig.tar.gz and put the sub-directory package into the site-packages directory of a FreeCAD installation.
I'm not following you. Do I need to change anything in the handling of version checking?
wmayer
Founder
Posts: 18819
Joined: Thu Feb 19, 2009 10:32 am

Re: Problems with path and Python 3.6

Post by wmayer »

sliptonic wrote: Sat Jul 02, 2022 4:50 pm I'm not following you. Do I need to change anything in the handling of version checking?
No, you don't have to.
david69
Veteran
Posts: 1090
Joined: Wed Jan 01, 2014 7:48 pm

Re: Problems with path and Python 3.6

Post by david69 »

here are my information:

Code: Select all

OS: Ubuntu 18.04.6 LTS (LXDE/Lubuntu)
Word size of FreeCAD: 64-bit
Version: 0.21.
Build type: Release
Branch: unknown
Hash: e2e58f7bffc6012e757181af57272383677d3d91
Python 3.6.9, Qt 5.9.5, Coin 4.0.0a, Vtk 7.1.1, OCC 7.5.2
Locale: French/France (fr_FR)
Installed mods: 
  * Help 1.0.3
I have downloaded manually python3-packaging, version17.1-1 thru synaptic. Is there a min required version?
reset FreeCAD and launch Path workbench and I've got the following error:

Code: Select all

15:46:19  __init__() got an unexpected keyword argument 'capture_output'
15:46:19  Traceback (most recent call last):
  File "<string>", line 164, in Initialize
  File "/usr/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
Edit: read again this thread and same point as
wmayer wrote: Sat Jul 02, 2022 9:08 am
The Python version 3.6 of SuSE Leap 15.3 does not have a subprocess capture_output.
wmayer
Founder
Posts: 18819
Joined: Thu Feb 19, 2009 10:32 am

Re: Problems with path and Python 3.6

Post by wmayer »

david69 wrote: Sat Jul 16, 2022 1:49 pm I have downloaded manually python3-packaging, version17.1-1 thru synaptic. Is there a min required version?
reset FreeCAD and launch Path workbench and I've got the following error:
When I switch to the Path wb then it loads without errors. But I guess it's just luck that it doesn't trigger an error for me. When I execute this Python snippet I get the same error as you:

Code: Select all

import subprocess
subprocess.run(["camotics", "--version"], capture_output=True, text=True)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/python3.6/subprocess.py", line 423, in run
with Popen(*popenargs, **kwargs) as process:
TypeError: __init__() got an unexpected keyword argument 'capture_output'
david69
Veteran
Posts: 1090
Joined: Wed Jan 01, 2014 7:48 pm

Re: Problems with path and Python 3.6

Post by david69 »

with

Code: Select all

OS: Ubuntu 18.04.6 LTS (LXDE/Lubuntu)
Word size of FreeCAD: 64-bit
Version: 0.21.
Build type: Release
Branch: unknown
Hash: 3137a81604ae1cdbdc80b2ba25c349a3ed00da0b
Python 3.6.9, Qt 5.9.5, Coin 4.0.0a, Vtk 7.1.1, OCC 7.5.2
Locale: French/France (fr_FR)
Installed mods: 
  * Help 1.0.3
I start Freecad, select Path workbench, I've got

Code: Select all

08:51:39  Import.so: Ne peut ouvrir le fichier d'objet partagé: Aucun fichier ou dossier de ce type
08:51:39  Traceback (most recent call last):
  File "<string>", line 62, in Initialize
  File "/usr/share/freecad-daily/Mod/Path/PathScripts/PathPreferencesPathJob.py", line 24, in <module>
    import Path
surprising to read a sentence in French, I've put the GUI in English.
Post Reply