• Register
0 votes
43 views

In an XML doument I was trying to build an python tool. It should distribute EXE form But it gives me an error like:

cx_freeze python error in main script-ImportError :DLL Load

my setup.py file is:

import sys
from cx_Freeze import setup, Executable

base = None
if sys.platform == 'win32':
    base = 'Win32GUI'

executables = [
    Executable('xin.py', base=base)
]

setup(name='XGen',
      version='0.1',
      description='XGen',
      executables=executables
      )

And the code I have written for my tool is:

from tkinter import filedialog
from tkinter import *
from pathlib import Path
import winsound
from lxml import etree
import csv

root = Tk()

root.geometry("250x200")
root.resizable(0, 0)


class gui:
    def __init__(self, master):
        self.master = master
        master.title("XGen")

        self.welcome = Label(master, text="Welcome to")
        self.welcome.config(font=("Arial", 10))
        self.welcome.pack()

        self.header = Label(master, text="The XPath Generator")
        self.header.config(font=("Arial", 16))
        self.header.pack()

        self.description = Label(master, text="This Tool Takes in an XML Document\nand Provides all its XPaths")
        self.description.config(font=("Arial", 10))
        self.description.pack()

        self.greet_button = Button(master, text="Select Input XML", command=self.greet)
        self.greet_button.pack()

        self.reportFilename = Label(master, text="")
        self.reportFilename.pack()

        self.reportProgress = Label(master, text="")
        self.reportProgress.pack()

        # self.close_button = Button(master, text="Close", command=master.quit)
        # self.close_button.pack()

    def greet(self):
        print("File Selection Started")

        from_file_path = filedialog.askopenfilename(initialdir="/",
                                                    title="Select file",
                                                    filetypes=(("XML Files", "*.xml"), ("all files", "*.*")))

        from_file_path_split = Path(from_file_path).parts
        to_file_path = ''

        if from_file_path is '':
            self.reportFilename.config(text="You Did not Select a File")
            print("No File Selected. File Selection Ended")

        else:
            self.reportFilename.config(text="You Selected " + from_file_path_split[-1])
            print("From File Path = " + from_file_path)
            print("File Name = " + from_file_path_split[-1])
            to_file_path = filedialog.asksaveasfilename(initialdir=from_file_path,
                                                        title="Save As",
                                                        filetypes=(("CSV Files", "*.csv"), ("all files", "*.*")))

        if to_file_path is '' or to_file_path == 'Null':
            self.reportProgress.config(text="Please select a Save Location")
        # elif to_file_split[-1][:4] == "xsd":
        else:
            to_file_split = Path(to_file_path).parts
            to_file_name = to_file_split[-1]
            print("Filename = " + to_file_name)

            to_file_extension = to_file_split[-1][-4:]
            print("Last 4 chars = " + to_file_extension)

            if to_file_extension == ".csv":
                pass
            else:
                to_file_path = to_file_path + ".csv"
                # to_file_name = to_file_path
                print("To File Path = " + to_file_path)

            if from_file_path == '' or to_file_path == '' or to_file_path == 'Null':

                self.reportProgress.config(text="Please Select a Valid XML File")
                winsound.PlaySound("SystemExclamation", winsound.SND_ALIAS)
                print("Bad File, Try Again")

            else:
                out(from_file_path, to_file_path)

                self.reportProgress.config(text="Generated " + Path(to_file_path).parts[-1])
                print("XGen Complete")


def out(in_path, out_path):
    with open(in_path, 'r') as source_file:
        xml = source_file.read()

    root = etree.fromstring(xml)

    tree = etree.ElementTree(root)

    line = ['XPath', 'Attribute Name', 'Current Data']
from tkinter import filedialog
from tkinter import *
from pathlib import Path
import winsound
from lxml import etree
import csv

root = Tk()

root.geometry("250x200")
root.resizable(0, 0)


class gui:
    def __init__(self, master):
        self.master = master
        master.title("XGen")

        self.welcome = Label(master, text="Welcome to")
        self.welcome.config(font=("Arial", 10))
        self.welcome.pack()

        self.header = Label(master, text="The XPath Generator")
        self.header.config(font=("Arial", 16))
        self.header.pack()

        self.description = Label(master, text="This Tool Takes in an XML Document\nand Provides all its XPaths")
        self.description.config(font=("Arial", 10))
        self.description.pack()

        self.greet_button = Button(master, text="Select Input XML", command=self.greet)
        self.greet_button.pack()

        self.reportFilename = Label(master, text="")
        self.reportFilename.pack()

        self.reportProgress = Label(master, text="")
        self.reportProgress.pack()

        # self.close_button = Button(master, text="Close", command=master.quit)
        # self.close_button.pack()

    def greet(self):
        print("File Selection Started")

        from_file_path = filedialog.askopenfilename(initialdir="/",
                                                    title="Select file",
                                                    filetypes=(("XML Files", "*.xml"), ("all files", "*.*")))

        from_file_path_split = Path(from_file_path).parts
        to_file_path = ''

        if from_file_path is '':
            self.reportFilename.config(text="You Did not Select a File")
            print("No File Selected. File Selection Ended")

        else:
            self.reportFilename.config(text="You Selected " + from_file_path_split[-1])
            print("From File Path = " + from_file_path)
            print("File Name = " + from_file_path_split[-1])
            to_file_path = filedialog.asksaveasfilename(initialdir=from_file_path,
                                                        title="Save As",
                                                        filetypes=(("CSV Files", "*.csv"), ("all files", "*.*")))

        if to_file_path is '' or to_file_path == 'Null':
            self.reportProgress.config(text="Please select a Save Location")
        # elif to_file_split[-1][:4] == "xsd":
        else:
            to_file_split = Path(to_file_path).parts
            to_file_name = to_file_split[-1]
            print("Filename = " + to_file_name)

            to_file_extension = to_file_split[-1][-4:]
            print("Last 4 chars = " + to_file_extension)

            if to_file_extension == ".csv":
                pass
            else:
                to_file_path = to_file_path + ".csv"
                # to_file_name = to_file_path
                print("To File Path = " + to_file_path)

            if from_file_path == '' or to_file_path == '' or to_file_path == 'Null':

                self.reportProgress.config(text="Please Select a Valid XML File")
                winsound.PlaySound("SystemExclamation", winsound.SND_ALIAS)
                print("Bad File, Try Again")

            else:
                out(from_file_path, to_file_path)

                self.reportProgress.config(text="Generated " + Path(to_file_path).parts[-1])
                print("XGen Complete")


def out(in_path, out_path):
    with open(in_path, 'r') as source_file:
        xml = source_file.read()

    root = etree.fromstring(xml)

    tree = etree.ElementTree(root)

    line = ['XPath', 'Attribute Name', 'Current Data']

It builds the Programm with an EXE but when the EXE runs it return the same error.

10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

0 votes

Your location of you DLL tool file must be added in your setup.py file. Default directory for your DLL tool file should be:

C:\Users\USER\AppData\Local\Programs\Python\DLLs

You must add a variable to store this path.
Then i should be converted in raw string with

r

That code should be like:

​
systempath = r'​C:\Users\USER\AppData\Local\Programs\Python\DLLs'

 

11 6 4
34,950 points

Related questions

0 votes
1 answer 67 views
67 views
Problem: I am trying to install python package rpy2 with pip install on Ubuntu 16.04: pip install rpy2==2.2.7 but get error message (see full output below): Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-EuOI6K/unroll/
asked Jan 10 Mashhoodch 13k points
0 votes
3 answers 271 views
271 views
I am new in python programming. I am tryin gto iinstall some packages with pip commands. I tried to install a package called unroll by using the command: pip[ install unroll but it gives me some error like : "python setup.py egg_info" failed with error code 1 How can I solve this problem? How can I check my pip version? How can I upgrade my pip version?
asked Mar 9, 2020 LizzyM 6.1k points
0 votes
1 answer 28 views
28 views
Problem: I have large json data that reads into a python dataframe and creates a list of dicts for each line. I need to convert it to a different data format. The data format is as follows: { "data": [{ "item": [{ "value": 0, "type": "a" }, { " ... ) df = df_formatted.fillna(0) The number of items in a list is often in the thousands. Are there pointers or examples on how to do this efficiently?
asked Dec 23, 2020 sasha 16.2k points
0 votes
1 answer 14 views
14 views
Problem: How to fix this error: socket.error: command python setup.py egg_info failed HELP! I need help understanding this error: command python setup.py egg_info failed Can someone please help fix this, I am new in python() : command python setup.py egg_info failed
asked Mar 1 Mashhoodch 13k points
0 votes
1 answer 51 views
51 views
Problem: A numpy matrix can be reshaped into a vector using reshape function with parameter -1. But I don't know what -1 means here. For example: a = numpy.matrix([[1, 2, 3, 4], [5, 6, 7, 8]]) b = numpy.reshape(a, -1) The result of b is: matrix ... anyone know what -1 means here? And it seems python assign -1 several meanings, such as: array[-1] means the last element. Can you give an explanation?
asked Jan 7 Mashhoodch 13k points
0 votes
1 answer 16 views
16 views
Problem: I tried to combine two lists: Names and Age. But I wanted to do this by adding their index [i + 1] to a different list each time. So instead of ['John', '17', 'Mike', '21'], my goal was for each pair to have its own index and be a list item. ... the path in the attached code, I achieve what I am trying to do. Can anyone explain why this works? I couldn't catch it. Thank you in advance.
asked Dec 24, 2020 sasha 16.2k points
2 votes
1 answer 50 views
50 views
Problem: I am new in programming language. I was trying to setup and then upgrade gcloud using python. I used the command: pip install --upgrade gcloud After that it shows: Collecting gcloud Downloading gcloud-0.18.3.tar.gz (454kB) 100% | ... code 1 in C:\Users\bid\AppData\Local\Temp\pip-build-ppc44asr\googleapis-common-protos\ Whats is happening here can anyone help?
asked Mar 24, 2020 LizzyM 6.1k points
0 votes
1 answer 16 views
16 views
Problem: I am new to programming language. Yesterday I installed python in system. I went to my command prompmt and run the command : python and it shows: Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 01:54:44) [MSC v.1916 64 bit (AMD64)] on ... a different output : python' is not recognized as an internal or external command, operable program or batch file Why am I seeig this , Please help.
asked Mar 22, 2020 LizzyM 6.1k points
0 votes
1 answer 2.1K views
2.1K views
I am trying to create a rating data frame for some football teams. To rate the teams I am using elo rating system : https://en.wikipedia.org/wiki/Elo_rating_system My data frame consists of pre-match ratings of home and away teams and it gets updated after every match. My data ... of size 1 to a python scalar Can any one help me to find what the problem really is and help me to solve the problem.
asked Mar 10, 2020 LizzyM 6.1k points