【问题标题】:Cannot build Pandas from setup.py in Wine environment无法在 Wine 环境中从 setup.py 构建 Pandas
【发布时间】:2018-05-08 07:14:17
【问题描述】:

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

运行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?

【问题讨论】:

  • 我一直是experimenting a lot with Python on Wine - 我很惊讶地看到您首先设法在 Wine 上安装和运行 CPython 3.6。 a bug in Wine which prevented running CPython 3.6AFAIK 已经有一段时间了。一个补丁最近才添加到 Wine-staging 中。您看到的错误对我来说是新的,但我仍然想建议尝试 3.5.x。 CPython 3.6 在 Windows API 使用方面进行了现代化改造,这也可能导致您的问题。你能查一下吗?
  • @s-m-e 在摆弄了一段时间没有成功之后,我暂时搁置了让我的脚本交叉编译的努力。 CPython 3.6 问题令人头疼。一旦我再次开始工作,我会告诉你是否可以在 3.5 上工作。

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


【解决方案1】:

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

此问题是由于 pandas 中的隐藏导入/pyinstaller 中缺少挂钩造成的。通过在 drive_c/Python*/Lib/site-packages/PyInstaller/hooks 中添加 this 挂钩文件解决了这个问题。在this github issue 中讨论并通过上面的链接解决。

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

一旦我解决了这个问题,我就开始收到一个与 numpy 相关的错误(我不记得它到底是什么,我认为它涉及日期并且它是在导入 numpy 或 pandas 因为我使用的是 test 。 py 基本上只是这样做的)通过使用 pip 卸载和重新安装熊猫来解决(在我的情况下,在 /path/to/drive_c/Python27 中使用“wine python.exe ./Scripts/pip.exe 卸载熊猫”)。最后,我发现this site 有助于理解如何在 wine 环境中工作(例如如何在 wine 中使用 pip)。

【讨论】:

    猜你喜欢
    • 2012-05-15
    • 1970-01-01
    • 2012-05-01
    • 2012-11-26
    • 2013-02-09
    • 1970-01-01
    • 2019-08-28
    • 2016-05-02
    • 2019-07-09
    相关资源
    最近更新 更多