Python 3 addon manager

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
schupin
Posts: 476
Joined: Sun Jan 21, 2018 1:43 pm

Python 3 addon manager

Post by schupin »

Hi,

I'm trying the conda version and I've got this error message when I click on the macro "center of mass" in the addon manager :

Code: Select all

GitPython not installed! Cannot retrieve macros from gitTraceback (most recent call last):
  File "/Applications/FreeCAD Py3.app/Contents/Mod/AddonManager/AddonManager.py", line 814, in run
    self.macro.fill_details_from_wiki(url)
  File "/Applications/FreeCAD Py3.app/Contents/Mod/AddonManager/addonmanager_macro.py", line 123, in fill_details_from_wiki
    response += data
TypeError: must be str, not bytes
OS: macOS 10.13
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15525 (Git)
Build type: Release
Branch: master
Hash: 1a7d3d9a37fe43468c8ac84590c1db53e2b2000a
Python version: 3.6.7
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)

Does anyone knows how to correct it ?
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Python 3 addon manager

Post by GeneFC »

This has already been corrected in later versions, but I do not know the exact version status for macOS.

The problem is that Python 3 is a bit more strict about data types in the print statement.

Search the offending file for something like "print(wb)", and remove the "b".

Gene
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Python 3 addon manager

Post by sgrogan »

As this is python only can can copy/replace the file from the FreeCAd sources over your local version.
https://github.com/FreeCAD/FreeCAD/blob ... Manager.py
"fight the good fight"
schupin
Posts: 476
Joined: Sun Jan 21, 2018 1:43 pm

Re: Python 3 addon manager

Post by schupin »

sgrogan wrote: Sun Mar 03, 2019 4:05 pm As this is python only can can copy/replace the file from the FreeCAd sources over your local version.
https://github.com/FreeCAD/FreeCAD/blob ... Manager.py
Thanks, I replaced AddonManager.py and addonmanager_macro.py and it's working.

By the way, it seems that there is other issues on several workbenches :

Code: Select all

During initialization the error invalid syntax (<string>, line 69) occurred in /Users/nous/Library/Preferences/FreeCAD/Mod/Animation-master 2/InitGui.py
Please look into the log file for further information
During initialization the error invalid syntax (<string>, line 58) occurred in /Users/nous/Library/Preferences/FreeCAD/Mod/workfeature/InitGui.py
Please look into the log file for further information
During initialization the error 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128) occurred in /Users/nous/Library/Preferences/FreeCAD/Mod/fasteners/InitGui.py
Please look into the log file for further information
During initialization the error 'ascii' codec can't decode byte 0xc3 in position 98: ordinal not in range(128) occurred in /Users/nous/Library/Preferences/FreeCAD/Mod/ExplodedAssembly/InitGui.py
Please look into the log file for further information
During initialization the error 'ascii' codec can't decode byte 0xc3 in position 76: ordinal not in range(128) occurred in /Users/nous/Library/Preferences/FreeCAD/Mod/VoxelWorkbench/InitGui.py
Looks like they have the same problem than me : Macro center of mass : py3 and unicode
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: Python 3 addon manager

Post by mario52 »

Hi

same error after install by AddonManager:

original line (Macro_FCInfo):

Code: Select all

        angle = str(deg)+u"° "+str(min)+u"' "+str(sec)+u"''"
error

Code: Select all

        angle = str(deg)+u"� "+str(min)+u"' "+str(sec)+u"''"
<unknown exception traceback><class 'SyntaxError'>: ("(unicode error) 'utf-8' codec can't decode byte 0xb0 in position 0: invalid start byte", ('C:/Users/xxxx/AppData/Roaming/FreeCAD/Macro/FCInfo.FCMacro', 145, 25, None))

with:

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16474 (Git)
Build type: Release
Branch: master
Hash: 746997e48411f22a150b95b6fdbb9b02cbe741d5
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0

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.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Python 3 addon manager

Post by vocx »

mario52 wrote: Wed Apr 17, 2019 2:56 pm Hi

same error after install by AddonManager:

original line (Macro_FCInfo):

Code: Select all

        angle = str(deg)+u"° "+str(min)+u"' "+str(sec)+u"''"
error

Code: Select all

        angle = str(deg)+u"� "+str(min)+u"' "+str(sec)+u"''"
<unknown exception traceback><class 'SyntaxError'>: ("(unicode error) 'utf-8' codec can't decode byte 0xb0 in position 0: invalid start byte", ('C:/Users/xxxx/AppData/Roaming/FreeCAD/Macro/FCInfo.FCMacro', 145, 25, None))
Errors like this are hard to figure out because it may be the case that the user is writing text in a codification that is not ANSI nor UTF8.

Many people that use accented languages like French, Spanish, Italian, German, etc., often use European code pages like Latin-1 (ISO 8859-1), or Windows-1252, or something like that. This is especially troublesome when adding a special character, like the degree symbol, or an accented letter like à, or ö. If the code page is not correctly set, Python will assume UTF8, but that doesn't fix the issue, it just shows a strange character.

So, who knows where the error is. It could be in the Addon Manager, or it could be in the macro itself. In that case, the macro should be correctly written (rewritten) in UTF8.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
mario52
Veteran
Posts: 4692
Joined: Wed May 16, 2012 2:13 pm

Re: Python 3 addon manager

Post by mario52 »

hi

yes many difficult with the character over 127 now + 30 years "informatique grand pubic" and always problems ??

but this problem is with only the two FreeCAD mentioned working with Python version: 3.6.6 and Qt version: 5.6.2 if you download the macro with all other FC configuration the download is right

--good--
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce
Python version: 2.7.14
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.2.0


here same version same Hash but Python version: 3.6.6 and Qt version: 5.6.2 and not work (FC 0.18 stable)
--not good--
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16093 (Git)
Build type: Release
Branch: releases/FreeCAD-0-18
Hash: 690774c0effe4fd7b8d2b5e2fb2b8c8d145e21ce

Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0



--not good--
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16474 (Git)
Build type: Release
Branch: master
Hash: 746997e48411f22a150b95b6fdbb9b02cbe741d5
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0


addonmanager_macro.py and AddonManager.py are the same
vocx wrote: Wed Apr 17, 2019 4:37 pm the macro should be correctly written (rewritten) in UTF8.
i have upgrade yesterday my macro FCInfo and i comment this line (and other modification) for run all FreeCAD
(0.18 stable and 0.19 the button not work)

Code: Select all

# ori 0.18 Py 27       text = text.encode('utf-8')                         # PySide
or work as this Macro FCInfo Alternate Linux but the problem stay.

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.
Post Reply