I am trying to make simple python program that is opening list of webpages for a user to manually download reports from the site. I don't have any previous experience with preparing exe files.. And I'm just in learning process for python coding. All of 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"]
}
},
)
First issue I had to resolved was a missing files (webdriver.xpi and webdriver_prefs.json) from selenium package, but I've successfully included them in to library.rar file after compilation by hand. Unfortunately right know after running my file I get message:
Fatal Python error: Py_Initialize: unable to load the file system codec
ImportError: No module named 'encodings'
I have the same error when I install Anaconda with Python 3.6. The error is resolved by adding an environment variable "PYTHONPATH" which point to the installation location of Python.
I refer to the following link,
Py_Initialize fails - unable to load the file system codec
anacondapython