I have created an executable Python script with pyinstaller that reads txt files with Pandas.
When I am running it through terminal it works fine, but when I double click it, console appears, and disappears immediately. I have also change the .spec file by defining datas=["./f.txt"],hiddenimports=['pandas','os','numpy'] Python script and f.txt are under the same directory.
Below is the script:
#!/usr/bin/python2
import os.path
import pandas as pd
import numpy as np
myfile = os.path.join(os.path.dirname(__file__), './f.txt')
df = pd.read_csv(myfile,sep='\s+,|\t',skiprows=[0,1,2,3,4,5,6,7,8,9,10,11,12], engine='python')
print df
input("Hit enter to close.")
When using pyinstaller, it will be run from 'INSTALLATION_DIR/_internal' folder, so most likely it cannot find the 'f.txt' file, you can verify it by running it from the terminal, and should find something like:
If this is your case, you have 2 possible solutions: