path - python code works but not in p2exe executable -


The following code works on its own. I have made executable with py2exe which is not working. The script manages the process and some CSV files, if I put this code in the "dist" directory where executable is executed (hence it is processed in depth of CSV files), the code works; But in the same directory, executable does not work.

import code import pandas pd as current_dir = os.path.dirname (os.path.realpath (__ file__)) directory = Os.path.sep.join (current_dir.split () Os.path.sep) [: - 2]) csvfiles = os.path.join (directory, '* .csv') for csvfile in glob.glob (csvfiles): file name = os.path.basename (csvfile) If '_sorted' is in the file name: Print "Remove this file" os.remove (csvfile) csvfiles = os.path.join (directory, '* .csv') glob in glob (csvfiles) for csvfile: filename = csvfile Df = pd.read_csv (filename) df = df [df ["ORGANIZATION"]! = "WPPL"] df = df.sort ('meeting time start') # New CSV file type df .to_csv (file name + '_sorted.csv', cols = ["DATE", "meeting start time", "meeting

In addition to the raw input ("End time", "description", "organization", "location"], index = incorrect) raw_input (press "Enter" to turn off) The statement screen is not open so I can not really see what is happening.

Thanks

Data files as relative paths To dump the dirname (__ file__) is actually a bad idea, unless you want to run the program in the construction tree only if you want to be able to install and run the program - Whether using py2exe or any other system - you are only asking for trouble.

If you are trying to package files with executables, then how to do this From py2exe If you can install and use the setuptools , then with the system, or more powerful and flexible mechanism

If, on the other hand, you install the user to your app After you want to supply CSV files, you almost certainly do not want to put them in your app's directory. Common tasks are to access them as routes related to the current working directory. In other words, just use . , no dirname (__file__) .

But, if you really want to do this ... The problem is that __ file____ is the file name of your main script - of course when you run a bundle executable If not then are not useful.

You can use sys.argv [0] or sys.executable depending on your usage case.

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -