pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.51k stars 17.87k forks source link

pandas 0.15+ is not deployable via py2app with python 3.4.2 #8602

Closed skycaptain closed 9 years ago

skycaptain commented 9 years ago

I'm deploying an PyQt(5.3.2) application using py2app. Everything works fine with 0.14.1, 0.15.0 fails at importing. As an example one can take the following main.py:

import pandas

def main():
  x = pandas.Series([0, 1, 2])
  print(x)

if __name__ == "__main__":
  main()

and use the default setup.py:

from setuptools import setup
import py2app

setup(
    app=['main.py'],
    options={'py2app': {'argv_emulation': True}},
    setup_requires=['py2app'],
)

and run python3 setup.py py2app to build the .app and then start the application (Please note the example can only be runned via Terminal, since it lacks a GUI)

In both Python 2.7.8 and 3.4.2 the .app builds fine but fails on 3.4.2 to start and dumps (stripped to the helpful parts):

'module' object has no attribute '__pyx_capi__'
2014-10-22 19:36:32.784 main[26763:321107] main Error
    Traceback (most recent call last):
File ".../dist/main.app/Contents/Resources/__     _run()
File ".../dist/main.app/Contents/Resources/__     exec(compile(source, path, 'exec'), globals(), globals())
File ".../dist/main.app/Contents/Resources/main.     import pandas
File "pandas/__init__.pyc", line 7, in <module>
File "pandas/tslib.pyc", line 14, in <module>
File "pandas/tslib.pyc", line 10, in __load
File "pandas/tslib.pyx", line 2839, in init pandas.tslib (pandas/tslib.c:80041)
File "pandas/algos.pyc", line 14, in <module>
File "pandas/algos.pyc", line 10, in __load
File "pandas/algos.pyx", line 64, in init pandas.algos (pandas/algos.c:180213)
File "pandas/lib.pyc", line 14, in <module>
File "pandas/lib.pyc", line 10, in __load
File "pandas/lib.pyx", line 1, in init pandas.lib (pandas/lib.c:78098)
    AttributeError: 'module' object has no attribute '__pyx_capi__'

If the example would run as expected it would print (again stripped):

0    0
1    1
2    2
dtype: int64
aimboden commented 9 years ago

Any updates/pointers on this issue? I encounter the same problem on pandas 0.15.1 and python 3.3.5 with essentially the same traceback while using the latest version of cx_freeze.

jreback commented 9 years ago

maybe make sure you have latests cython/numpy

no idea how these apps work - you should ask on their ml

skycaptain commented 9 years ago

I've installed all numpy, cython and pandas via git on their master branches. Sadly the issue still exists. I've also diffed the pandas 0.14.1 and 0.15 branch, to see what changes may interfere with py2app. But i wasn't lucky yet. i'm really starting to think that this issue related to the way pandas is build, which is more complex in combination with the build tools provided by py2app.

Update: I've traced down this issue to commit 84404afc6eec53e3d31ee9298cecf2b3c2de1d8c. before that commit everything worked fine. obviously this was the time tslib.pyx started to import pandas.algos as algos. every other change looks harmless.

jtratner commented 9 years ago

Granted, my Cython knowledge is not amazing, but I'm guessing this is the problem - https://groups.google.com/forum/#!msg/cython-users/MDyJdhbYL_8/MLlG790pRLUJ

The reason why you would get the above error is that you are trying to cimport things (my guess is functions) from another module (and Cython finds them declared in a .pxd file at compile time), but that module doesn't actually export a C-API, so it can't import them at runtime.

Looking around, it seems like this is a bit complex. Given that it's duplicating 4 lines between files, anybody mind just reverting that one portion to make this work everywhere?

jreback commented 9 years ago

@skycaptain if you want to try to build from this PR #8830 and see if that fixes the issue

skycaptain commented 9 years ago

@jreback as far as my venv is not lying or i did sth wrong, your pr fixed the issue for my given example. i will merge your pr with my recent project and report back by tomorrow.

jreback commented 9 years ago

haha

ok lmk and we can put this in the next release

skycaptain commented 9 years ago

@jreback had to update und merge the project anyway. as far as i can tell the app starts and works as expected. thank you!

jreback commented 9 years ago

closed by #8830