Failed to get the Python codec of the filesystem encoding

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
jerryust
Posts: 2
Joined: Thu Jul 15, 2021 10:38 am

Failed to get the Python codec of the filesystem encoding

Post by jerryust »

Hello! I'm a newbie to FreeCAD development. Currently I'm trying to debug the Freecad on Windows using the latest libpack and Freecad 0.2 source code.

After following the instructions on wiki I have successfully compiled the Release mode and installed the FreeCAD 0.2, and it can run properly.

I have also successfully compiled the Debug mode. But After I set the FreeCADMain as the start project and run the debugger in vs2019, the output gives out "Fatal Python error: failed to get the Python codec of the filesystem encoding" and then the program exit with code 1.

I have no idea why this happens. This is the output:

'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreecadBuild\bin\FreeCAD_d.exe'. Symbols loaded.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\shell32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreecadBuild\bin\FreeCADApp_d.dll'. Symbols loaded.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreecadBuild\bin\FreeCADGui_d.dll'. Symbols loaded.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreecadBuild\bin\FreeCADBase_d.dll'. Symbols loaded.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'.
'FreeCAD_d.exe' (Win32): Unloaded 'C:\Windows\System32\advapi32.dll'
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140d.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140_1d.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\Qt5Cored.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\Qt5Widgetsd.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\python38_d.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\Qt5Guid.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'.
'FreeCAD_d.exe' (Win32): Unloaded 'C:\Windows\System32\ole32.dll'
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\zlibd.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\boost_regex-vc141-mt-gd-x64-1_67.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\xerces-c_3_2D.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\boost_filesystem-vc141-mt-gd-x64-1_67.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\boost_program_options-vc141-mt-gd-x64-1_67.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\Qt5Xmld.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\shfolder.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\opengl32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\hid.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\Coin4d.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\Qt5PrintSupportd.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\Qt5Svgd.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\Qt5WinExtrasd.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\comdlg32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\SHCore.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\pyside2_d.cp38-win_amd64.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\shiboken2_d.cp38-win_amd64.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\Qt5Networkd.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\mpr.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\crypt32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\userenv.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\netapi32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\dwmapi.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\uxtheme.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140_1d.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\d3d11.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\dxgi.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\winmm.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\glu32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\winspool.drv'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_5.82.19041.1110_none_792d1c772443f647\comctl32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\dnsapi.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\boost_system-vc141-mt-gd-x64-1_67.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\IPHLPAPI.DLL'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\FREECAD\FreeCADLibs_12.5.2_x64_VC17\bin\Qt5Qmld.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\srvcli.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\netutils.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\cryptbase.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\nsi.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\windows.storage.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\wldp.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\cryptsp.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\rsaenh.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'.
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'.
Fatal Python error: failed to get the Python codec of the filesystem encoding
'FreeCAD_d.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'.
The thread 0x19e4 has exited with code 1 (0x1).
The thread 0x592c has exited with code 1 (0x1).
The thread 0x56cc has exited with code 1 (0x1).
The program '[12144] FreeCAD_d.exe' has exited with code 1 (0x1).
alexcfu
Posts: 5
Joined: Fri Feb 05, 2021 1:06 pm

Re: Failed to get the Python codec of the filesystem encoding

Post by alexcfu »

I ran into the exact same issue when building FreeCAD 0.19.3 in debug mode in visual studio. Has this been resolved? Would appreciate if anyone can share a resolution for this issue.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Failed to get the Python codec of the filesystem encoding

Post by GeneFC »

Check to see if there is any reference to Python in your Windows Environment Variables. In particular, remove any reference to Python in the Path variable.

For further reference read

https://discuss.python.org/t/fatal-pyth ... oding/3173

Gene
alexcfu
Posts: 5
Joined: Fri Feb 05, 2021 1:06 pm

Re: Failed to get the Python codec of the filesystem encoding

Post by alexcfu »

Thanks but I can confirm there is no reference to Python in my windows Env variables, and I have not installed any python in the system. Any idea on how to fix this?
GeneFC wrote: Thu Feb 24, 2022 3:07 pm Check to see if there is any reference to Python in your Windows Environment Variables. In particular, remove any reference to Python in the Path variable.

For further reference read

https://discuss.python.org/t/fatal-pyth ... oding/3173

Gene
helloworld55
Posts: 1
Joined: Sat Feb 26, 2022 8:55 pm

Re: Failed to get the Python codec of the filesystem encoding

Post by helloworld55 »

Does anyone know why this happens? I am trying to compile FreeCAD v0.19.3 following the wiki, and am getting stuck here. I have already tried removing all references to Python in my Path, and uninstalling python.

Thank you.
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Failed to get the Python codec of the filesystem encoding

Post by onekk »

alexcfu wrote: Fri Feb 25, 2022 1:46 am Thanks but I can confirm there is no reference to Python in my windows Env variables, and I have not installed any python in the system. Any idea on how to fix this?
This page could not help?

https://wiki.freecadweb.org/Compile_on_Windows
If it fails with a message about the wrong Python version or missing Python, then:

Use the "Search:" box in CMake to search for the string "Python"
If you see there a path like C:/Program Files/Python38/python.exe, CMake recognized the Python that is already installed on your PC, but that version is not compatible with the LibPack. Since the LibPack includes a compatible version of Python, modify the following Python settings in CMake to its paths (assuming the LibPack is in the folder D:\FreeCAD-build\FreeCADLibs_12.5.2_x64_VC17):
and the following lines of code..


If this is not helpful, try to report maybe the relevant error, netter if it is inclosed in "</>" so appearance is better.

Usually if you are developing, you have to install some requirements.

EDIT: This is wrong, sorry for any inconvenience. :oops:

Libpacks, usually are for running an already compiled version, so installing a libpack will not install the sources and the header for compiling.

END EDIT

But As I develop only on Linux, I don't know exactly, but i thing that a compiler is a compiler whatever OS you are using.


EDIT: also this could not be exact
A compiler need sources and header to compile something, so if you use an external library or a Language you have to install it by hand.


END EDIT

Regards

Carlo D.

PS: Hoping that having attired some attention on this problem some of the people that have noted my mistake, could help you.
Last edited by onekk on Mon Feb 28, 2022 1:55 pm, edited 1 time in total.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Failed to get the Python codec of the filesystem encoding

Post by adrianinsaval »

onekk wrote: Mon Feb 28, 2022 10:26 am https://wiki.freecadweb.org/Compile_on_Windows
...
Libpacks, usually are for running an already compiled version, so installing a libpack will not install the sources and the header for compiling.
from the wiki page you linked:
LibPack (also called FreeCADLibs). This is a single package containing all of the libraries necessary to compile FreeCAD on Windows
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Failed to get the Python codec of the filesystem encoding

Post by GeneFC »

onekk wrote: Mon Feb 28, 2022 10:26 am Libpacks, usually are for running an already compiled version, so installing a libpack will not install the sources and the header for compiling.
That is utterly and completely wrong. I compile frequently on Windows using the Libpack for a totally clean build. Everything needed is there.

There is no need to install Libpack for an already compiled version.

Gene
User avatar
onekk
Veteran
Posts: 6146
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Failed to get the Python codec of the filesystem encoding

Post by onekk »

GeneFC wrote: Mon Feb 28, 2022 1:45 pm That is utterly and completely wrong. I compile frequently on Windows using the Libpack for a totally clean build. Everything needed is there.
adrianinsaval wrote: Mon Feb 28, 2022 1:04 pm from the wiki page you linked:
LibPack (also called FreeCADLibs). This is a single package containing all of the libraries necessary to compile FreeCAD on Windows
Many thanks, sorry, I've corrected my original post.

But maybe if you are here and know better windows compiling, how to help the OP?

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: Failed to get the Python codec of the filesystem encoding

Post by GeneFC »

helloworld55 wrote: Sat Feb 26, 2022 8:57 pm I am trying to compile FreeCAD v0.19.3 following the wiki, and am getting stuck here.
Why are you trying to compile version 0.19? There are precompiled versions that already work.

If you want the latest updates it would make more sense to compile the master version 0.20. That is where the 1000's of improvements have been made.

Gene
Post Reply