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:
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)
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()
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'
source
share