我试图将一个简短的python脚本打包成一个可执行文件。我可以使用
pyinstaller script.py
但是,当我运行可执行文件时,会出现以下错误。我什么都试过了,似乎什么都没用。
C:\Users\...\Python\dist\script>script
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "c:\users\user\appdata\local\temp\pip-build-0pjuke\pyinstaller\PyInst
aller\loader\pyimod03_importers.py", line 363, in load_module
File "c:\python27\lib\site-packages\pandas\__init__.py", line 13, in <module>
"extensions first.".format(module))
ImportError: C extension: lib not built. If you want to import pandas from the s
ource directory, you may need to run 'python setup.py build_ext --inplace' to bu
ild the C extensions first.
script returned -1
以下是我脚本中的导入:
import pandas
from simple_salesforce import Salesforce
from pandas import Series, DataFrame
import vertica_python
from StringIO import StringIO
编辑
.spec
文件,在a = Analysis part
之后添加下面显示的行。然后使用--onefile flag
-例如pyinstaller --onefile my_project.spec
构建这是必要的,因为PyInstaller正在获取pandas的python代码,而不是获取lib。这意味着当pandas代码运行(从可执行文件的“内部”运行)时,它找不到lib,因此它试图提供帮助,并建议您需要构建它。
解决方法在http://github.com/pyinstaller/pyinstaller/issues/1580中有详细说明,它可能不适用于所有版本/操作系统,所以祝您好运。
错误
清楚地告诉您运行
python setup.py build_ext --inplace
。 构建C扩展相关问题 更多 >
编程相关推荐