Fatal Python error: Py_Initialize: Unable to load file system codec. ImportError: No module named 'encodings'

I am trying to make a simple python program that opens a list of web pages so that the user can manually download reports from the site. I have no previous experience preparing exe files. And I'm just learning the python coding process. All this is done on Windows 7 x64

This is my Python code:

#!C:/Python34/python.exe -u

from splinter import *
import time
import os
import csv

#----------------------------------
raporty = []
with open('../raporty.csv', newline='') as csvfile:
    contents = csv.reader(csvfile, delimiter=' ', quotechar='|')
    for row in contents:
        r = ', '.join(row)
        r = r.replace(',','')
        raporty.append(r)

#--not implemented yet
zmienne = []
with open('../zmienne.csv', newline='') as csvfile:
    contents = csv.reader(csvfile, delimiter=' ', quotechar='|')
    for row in contents:
        r = ', '.join(row)
        r = r.replace(',','')
        zmienne.append(r)

print("start")
browser = Browser()

#----------------LOGIN------------------
browser.visit('https://xxxx')
print(browser.title)
if browser.title == "xxxxxxxxxxxx":
    element = browser.find_by_name('login').first
    element.value = "xxxx"
    element2 = browser.find_by_name('password').first
    element2.value = "xxxx"
    browser.find_by_value('sign in').click()

time.sleep(5)

#----------------------------------
j = 1
for i in raporty:
    webpage = 'webpage_link'
    print("text" + i)
    browser.visit(webpage)
    j += 1

    if j > 15:
        time.sleep(j)
    else:
        time.sleep(12)

My setup.py file looks like this:

from distutils.core import setup
import py2exe

setup(
    console=['Final.py'],
    options={
            "py2exe":{
                    "skip_archive": True,
                    "unbuffered": True,
                    "optimize": 2,
                    "packages": ["encodings", "splinter"]
            }
    },
)

The first problem I had to solve was the lack of files (webdriver.xpi and webdriver_prefs.json) from the selenium package, but I successfully included them in the library.rar file after manual compilation. Unfortunately, I know that after running my file, I get the message:

Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'
+5
source share
4

, Anaconda Python 3.6. "PYTHONPATH", Python.

:

Py_Initialize -

+3

:

1. MAC OSX
2. ANACONDA

, Python , /, .

:

1. echo $PYTHONHOME
2. echo $$PYTHONPATH

, , .bashrc .bash_profile

1. export PYTHONHOME="/Users/<user>/anaconda3/""
2. export PYTHONPATH=$PYTHONHOME/bin

. , "encodings", .

find / -type d -name "encodings" , "encodings".

, .

rm -rf <directory>

0

: MAC OSX ANACONDA

, Python , /, .

:

1. echo $PYTHONHOME
2. echo $$PYTHONPATH

, , .bashrc .bash_profile

1. export PYTHONHOME="/Users/<user>/anaconda3/""
2. export PYTHONPATH=$PYTHONHOME/bin

. , "encodings", .

find / -type d -name "encodings" , "encodings".

, .

rm -rf <directory>

0

, , , .

Current thread 0x00003458 (most recent call first):
[Sun Oct 13 12:30:28.723435 2019] [mpm_winnt:crit] [pid 13320:tid 652] AH00419: master_main: create child process failed. Exiting.
[Sun Oct 13 12:30:43.403433 2019] [mpm_winnt:notice] [pid 16280:tid 660] AH00455: Apache/2.4.41 (Win64) mod_wsgi/4.6.8 Python/3.7 configured -- resuming normal operations
[Sun Oct 13 12:30:43.405433 2019] [mpm_winnt:notice] [pid 16280:tid 660] AH00456: Apache Lounge VS16 Server built: Aug  9 2019 16:46:32
[Sun Oct 13 12:30:43.405433 2019] [core:notice] [pid 16280:tid 660] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Sun Oct 13 12:30:43.486436 2019] [mpm_winnt:notice] [pid 16280:tid 660] AH00418: Parent: Created child process 14876
Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00003620 (most recent call first):
[Sun Oct 13 12:30:47.496434 2019] [mpm_winnt:crit] [pid 16280:tid 660] AH00419: master_main: create child process failed. Exiting.
0
source

All Articles