Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
139 views
in Technique[技术] by (71.8m points)

python - macos pyinstaller, missing pandas in executable

on mac, I've prepared script which takes all csv form current folder and saves it as json. after pyinstaller --onefile main.py or pyinstaller --onefile --hidden-import pandas main.py i run application and it says:

Traceback (most recent call last): File "main.py", line 1, in ModuleNotFoundError: No module named 'pandas' [84164] Failed to execute script main

My script code is:

import pandas
import os 
files = [f for f in os.listdir('.') if os.path.isfile(f)]
for f in files:
    if f.find('csv')>=0 and f.find('~')<0:
        try:
            excel_data_df = pandas.read_csv(f, header=0, delimiter=';')
            real_cols = [x for x in excel_data_df.columns if (not x.startswith("Unnamed: "))]
            excel_data_df = excel_data_df[real_cols]
            json_str = excel_data_df.to_json(orient='records',force_ascii=False) 
            g = open(f.replace('csv','json'), "w")
            g.write(json_str)
            g.close()
        except Exception as e:
            h = open('err.txt', "w")
            h.write(str(e)+' 
')
            h.close()

Script works. Run in PyCharm with venv. Pyinstaller command run in PyCharm terminal.

I have tried the same on windows machine. It worked. On mac it doesn't.

Why does it happen? What to do to have proper application?

question from:https://stackoverflow.com/questions/65897754/macos-pyinstaller-missing-pandas-in-executable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...