Python Forum

Full Version: Fatal Python error: initfsencoding: unable to load the file system codec
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Good Day Everyone

I am very new to Python programming and created program to compare two csv files and produce a result in Excel. The program worked fine so i created a exe by using pyinstaller. Pyinstaller created the exe with some warning. However, when i am trying to run the exe( from dist folder), i am getting below error:

Fatal Python error: initfsencoding: unable to load the file system codec
zipimport.ZipImportError: can't find module 'encodings'

Below is my current Python Version:
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32

When i setup PYTHONHOME and PYTHONPATH in the environment variable then i am getting same when i am even trying to open python 3.6 command prompt( before setting up the path, i was able to open the python 3.6 command prompt)

PYTHONHOME
C:\Users\gaurbhardwaj\AppData\Local\Programs\Python\Python37-32

PYTHONPATH
C:\Users\gaurbhardwaj\AppData\Local\Programs\Python\Python37-32\Lib\site-packages

Any help pointer/help would be highly appreciated!

Thanks
Gaurav
Environment variables don't matter when running a bundled package, since they're not used. That's the whole point of using Pyinstaller, it tries to guess what modules you import, then it bundles those together to create something that can run without python or other modules installed.

But that also means that sometimes Pyinstaller misses a few modules while looking for what you use. Because that's a pretty common thing to happen while bundling, the docs cover it: https://pythonhosted.org/PyInstaller/ope...gram-needs
Hi Nilamo

Thank you so much for the response, i really appreciate the help!

I read the note and i can understand that encodings module is missing but still could not figure out how to include it. I also read about hidden module but could not understand how to include. Could you please guide me on how to include encodings module in my script. Do i need to pipinstall it and then use import statement in .py script?

Thanks again for your help!

Thanks
Gaurav
How are you using it, if you're not already importing it somehow?
I am using below imports only so i am not sure why it is trying to import encodings module.

import pandas
import sqlite3
from tkinter import *
import tkinter
import tkinter.messagebox
import csv
from xlsxwriter.workbook import Workbook


Thanks Again!
Gaurav
https://github.com/pyinstaller/pyinstaller/issues/3642

I guess try it with the newest development version off github?
Hi Nilamo

I reviewed the notes and it talks about Python 3.6 resolves the issue but i am already on python 3.6 so not sure how to fix it?

Thanks
Gaurav
Also when i try to run the exe from cmd prompt, i get below error:

File "benefitenrollmentcompare.exe", line 1
SyntaxError: Non-UTF-8 code starting with '\x90' in file benefitenrollmentcompare.exe on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details.

I added below code but still getting the same error.

#!/usr/local/bin/python
# -*- coding: utf-8 -*-


Any help/pointer would be highly appreciated!

Thanks
Gaurav
(Nov-30-2018, 05:23 PM)gauravbhardwajee Wrote: [ -> ]but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details.
There is no need to declare encoding in Python 3.6 --> as utf-8 is default encoding.
Look at this thread,so when i test this out a always build virtual environment first(to make troubleshooting with pyinstaller easier if needed).
The you see after troubleshooting that this is needed to get pandas to work with pyinstaller.
hiddenimports=['pandas._libs.tslibs.timedeltas'],
You see i use same approach in Sound-player standalone.
There i use pipenv to build virtual environment,then build pyinstaller.
Hi Snippsat

Thank you so much for help, i really appreciate it!

I tried exact steps mentioned in payinstalled exe size but still getting same encondig error and also my exe size did not reduce( its 57MB).

I am writing my code in Notepad++, not sure if this is the issue.

Thanks
Gaurav
Pages: 1 2