无法在Wine环境中的setup.py中构建Pandas

时间:2017-11-24 09:45:00

标签: python python-3.x pandas pyinstaller wine

我正在尝试使用Wine将Python脚本从我的Linux平台交叉编译为Windows可执行文件。我已经成功安装了Python 3.6.0 for Windows 64位和pyinstaller,以及我的Wine环境中我的程序的所有Python依赖项。

正在运行wine py my_file.py正确运行我的程序而不会出现任何错误。但是,在尝试运行使用pyinstaller构建的交叉编译的.exe时,会引发以下错误:

File "site-packages\pandas\__init__.py", line 35, in <module>
ImportError: C extension: No module named 'pandas._libs.tslibs.timedeltas' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
[275] Failed to execute script parser

我使用git clone https://github.com/pandas-dev/pandas.git将Pandas源代码下载到我的Wine drive_c 文件夹中,然后运行wine py setup.py build_ext --inplace --force并收到以下错误:

fixme:ntdll:NtQueryInformationJobObject stub: 0x54 9 0x33eff0 112 0x33efec
install requires: 'python-dateutil < 2','numpy'.  use pip or easy_install.
   $ pip install 'python-dateutil < 2' 'numpy'
fixme:msvcrt:__clean_type_info_names_internal (0x1e1f9bc8) stub
fixme:ver:GetCurrentPackageId (0x33ef18 (nil)): stub

但是,运行wine py -m pip freeze表示我已经安装了这些模块的正确版本:

altgraph==0.14
beautifulsoup4==4.6.0
bs4==0.0.1
future==0.16.0
html5lib==0.999999999
lxml==4.1.1
macholib==1.8
numpy==1.13.3
pandas==0.21.0
pefile==2017.11.5
PyInstaller==3.3
pypiwin32==220
python-dateutil==1.5
pytz==2017.3
six==1.11.0
webencodings==0.5.1

我也可以从我的Python解释器中成功导入这些模块:

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import dateutil
>>> print(dateutil.__version__)
1.5
>>> import numpy
>>> print(numpy.__version__)
1.13.3
>>> 

是什么阻止我在Wine环境中构建Pandas?

1 个答案:

答案 0 :(得分:0)

我知道我迟到了,但希望这仍然会有所帮助和/或指出其他人正确的方向。

此问题是由pandas中的隐藏导入/ pyinstaller中的缺少钩子引起的。它通过在drive_c / Python * / Lib / site-packages / PyInstaller / hooks中添加this挂钩文件来解决。它在this github issue中讨论过,并通过上面的链接解决。

我能够在其他Stack Overflow问题中找到答案herehere

一旦我解决了这个问题,我开始得到一个与numpy有关的错误(我不记得它到底是什么,我认为它涉及日期,而且是因为我正在使用测试而导入numpy或pandas。通过卸载并重新安装带pip的pandas(在我的情况下,在/ path / to / drive_c / Python27中使用“wine python.exe ./Scripts/pip.exe uninstall pandas”)解决了py的问题。最后,我发现this site有助于理解如何在葡萄酒环境中工作(例如如何在葡萄酒中使用pip)。