How to package pandas, with pyinstaller and avoid some common mistakes

< H2 > question < / H2 >

I want to use pandas to generate a DataFrame input .csv file, but the packaged .exe file cannot be implemented after running.

< H2 > 1. Environment < / H2 >
  • Win10
  • Python3.6.4 (the latest version of Anaconda)
  • PyInstaller: 3.3.1

Code to be packaged ( amyfile.py )

import pandas as pd
import numpy as np
arr1 = np.arange(100).reshape(10,10)
data1 = pd.DataFrame(arr1)
data1.to_csv(r"D:\b.csv",index=False,header=False,decimal=",") 

the first pit, the error is as follows

"utf-8" codec can"t decode byte 0xce in position 122: invalid continuation....

solution: enter

in CMD
CHCP 65001
< H2 > 2. Tried method < / H2 >

(1) the first method

my younger brother has been Baidu many times before, including adding

to amyfile.spec .
def get_pandas_path():
    import pandas
    pandas_path = pandas.__path__[0]
    return pandas_path
 

dict_tree = Tree(get_pandas_path(), prefix="pandas", excludes=["*.pyc"])
a.datas += dict_tree
a.binaries = filter(lambda x: "pandas" not in x[0], a.binaries)

Link: [organize] PyInstaller packages for programs containing Python3.4, PyQt, Pandas, Multiprocess

in addition

(2) the second method

I need to go to GitHub to find a host file. I don"t know anything about host. I don"t know how to get the address given by the author. I don"t know where to put it. I wonder if it really works?
python-jiao-ben-de-yi-xie-xin-de/" rel=" nofollow noreferrer "> some experiences of PYINSTALLER packaging PYTHON script

< H2 > 3. Pandas and Numpy libraries are just missing in the packaged file < / H2 >

looked carefully at the warnamyfile.txt in the build file and found that none of the modules were imported, and all the libraries generated in dist were libraries I didn"t need.

Mar.01,2021
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b361f8-2b766.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b361f8-2b766.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?