Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pandas: C extension pandas.lib not included #1580

Closed
jksfiftyfive opened this issue Oct 5, 2015 · 22 comments
Closed

pandas: C extension pandas.lib not included #1580

jksfiftyfive opened this issue Oct 5, 2015 · 22 comments

Comments

@jksfiftyfive
Copy link

Hi,

Im using python 2.7.9 32 bit python on windows 7.

I tried this with the development version of pyinstaller

Im getting this error when trying to run my exe. it seems to build ok, but doesnt execute. The following message appears:

ImportError: C extension: lib not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
DataCombinerApp returned -1

I tried running, 'python setup.py build_ext --inplace' without luck.

I have found several suggestions on the web, including

  1. downloading VCC compiler for python 2.7 and re-installing pandas with zip/source
  2. uninstalling/installing panda using condas
    3)installing pandas using pip

still get the error

Any ideas?

thanks

@jksfiftyfive
Copy link
Author

i should also add that the code works fine. i dont get the error when running within python

im only having issues with the executable

@htgoebel
Copy link
Member

htgoebel commented Oct 5, 2015

You probably need to create a hook for pandas. See http://pythonhosted.org/PyInstaller/#understanding-pyinstaller-hooks. The description there should still be okay for your case.

@htgoebel htgoebel added kind:support area:hooks Caused by or effecting some hook labels Oct 5, 2015
@jksfiftyfive
Copy link
Author

But what file(s) should the hook point to? looks like its not complaining that it cant find the file, it looks like its complaining that a C extension file isnt built.

Any ideas?
thanks

@notgonnacodethat
Copy link

hi i'm experiencing the same problem, got the following error during build (both --onedir and --onefile) and running the .exe

ImportError: C extension: lib not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.

i tried to build with "python setup.py build_ext --inplace --force" as well as using pyinstaller 3.1.dev0, still no luck

@matysek
Copy link
Member

matysek commented Oct 9, 2015

But what file(s) should the hook point to? looks like its not complaining that it cant find the file, it looks like its complaining that a C extension file isnt built.

Any ideas?
thanks

@jksfiftyfive It looks like pyinstaller does not bundle C extension and pandas thus complains that it was not compiled.

@matysek matysek added platform:Windows state:need info Need more information for solve or help. Python:2 labels Oct 9, 2015
@dloman
Copy link

dloman commented Oct 9, 2015

I'm also having this issue trying to use pyinstaller on centos. I don't understand which files I need to add to hook.

I tried running with the --onedir, --onefile and --noupx flags

@dloman
Copy link

dloman commented Oct 9, 2015

fixed this issue on my end. Pyinstaller wasn't including `$PYTHONDIR/site-packages/pandas/lib.so`` just copied this into the dist directory and named it pandas.lib.so and it appears to be working. Pyinstaller is awesome keep up the good work!

@matysek matysek changed the title pandas: ImportError: C extension: lib not built. pandas: C extension pandas.lib not included Oct 10, 2015
@matysek matysek self-assigned this Oct 10, 2015
@matysek matysek added this to the PyInstaller 3.1 milestone Oct 10, 2015
@matysek matysek added @low platform:Linux state:verify This needs to be verified - would be great if someone could write a test-case for version:3.0 and removed state:need info Need more information for solve or help. kind:support labels Oct 10, 2015
@matysek
Copy link
Member

matysek commented Oct 10, 2015

@dloman thanks for debugging

@rth
Copy link
Contributor

rth commented Oct 11, 2015

@matysek Regarding your earlier comment,

Question is why do you need to compile anything with pandas yourself when there are prebuilt pandas wheel packages on pypi

I can confirm that the same issue occurs with prebuilt pandas package for anaconda on Windows 8.1 (python 2.7).

Here is a minimal working example:

test.py

import pandas as pd

assert pd.lib.is_float(1) == 0

Makefile.bat

conda create --yes -n test_env pip future nose cython setuptools=18 pywin32 libpython numpy=1.9 scipy=0.15 pandas=0.14 python=2
call activate test_env
pip install pyinstaller
pyinstaller test.py
call deactivate

The full build output can be found here with in particular this error:

IOError: [Errno 22] invalid mode ('rb') or filename: 'c:\\miniconda\\envs\test_env\\lib\\site-packages\\pandas\\lib.pyd'

which is strange since lib.pyd does exist in the system (although in C:\Miniconda\envs\test_env\Lib\site-packages\pandas I'm not sure why the path would be in lower case in the logs).

Edit: So, at least in anaconda on Windows, the problem is not that pandas.lib is not included by pyinstaller, but that the process errors while doing so (therefore I'm not sure if adding hooks etc will help). On Linux (Gentoo, system Python 2.7) I get the following error with the above test.py:

Traceback (most recent call last):
 File "<string>", line 5, in <module>
 File "pandas/lib.pyx", line 1, in init pandas.lib (pandas/lib.c:79957)
 File "/usr/lib64/python2.7/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 source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.

Where pandas was installed with the system package manager (portage), so normally everything is installed correctly (although, yes, it is compiled from sources). Same thing happens with Python 3.4.

Great work for the 3.0 release btw!

@notgonnacodethat
Copy link

@dloman thanks for your answer, works like a charm
for windows, just copy lib.pyd from pandas folder to dist folder and rename it to pandas.lib.pyd

@tallforasmurf
Copy link
Contributor

could this be managed with an added binaries item? As described here:
https://pythonhosted.org/PyInstaller/#adding-binary-files

@notgonnacodethat
Copy link

@tallforasmurf tried modifying the spec file by adding binary / data file, but the "pandas.lib.pyd" file will be automatically placed in "dist/pandas.lib.pyd" folder instead of the root "dist" folder and that doesn't work

anyone know how can I modify in the spec file so that a binary can placed in the same folder as the .exe?

@dloman
Copy link

dloman commented Oct 12, 2015

I also tried modifying the binaries section of the spec file and that didn't work. I got --onefile version working by first running pyinstaller --onefile pandasScript.py then going into the build directory and editing *Analysis.toc, *COLLECT.toc, *EXE.toc, and the *PKG.toc files. In all of those files I searched for the word hashtable and found this line ('pandas.hashtable', '/usr/local/lib/python2.7/site-packages/pandas/hashtable.so', 'EXTENSION'),. I added ('pandas.lib', '/usr/local/lib/python2.7/site-packages/pandas/lib.so', 'EXTENSION'), immeditaly following the hashtable line and then reran pyinstaller --onefile pandasScript.py and it works. Not sure why adding pandas.lib into the spec file didn’t work but this is an inelegant work around. Hope this helps

@tallforasmurf
Copy link
Contributor

@dloman if what you say is true, I think that if the following change to your spec file does not work,

a = Analysis([' ... script name ... '],
 ...
 binaries= [   (  '/usr/local/lib/python2.7/site-packages/pandas/lib.so', 'pandas.lib' ) ] ,
...

...then there must be a bug somewhere. Because that is exactly what the binaries arg is supposed to accomplish. (Somebody double-check my syntax plz?)

matysek added a commit that referenced this issue Oct 13, 2015
matysek added a commit that referenced this issue Oct 13, 2015
matysek added a commit that referenced this issue Oct 13, 2015
matysek added a commit that referenced this issue Oct 13, 2015
@matysek
Copy link
Member

matysek commented Oct 13, 2015

@jksfiftyfive @dloman or @rth could anyone of you confirm that these commits fix this issue?

@matysek matysek added state:need info Need more information for solve or help. and removed Python:2 state:verify This needs to be verified - would be great if someone could write a test-case for labels Oct 13, 2015
@rth
Copy link
Contributor

rth commented Oct 13, 2015

@matysek I can confirm that the above commits fixed the issue for me on Windows 8.1 with Anaconda, (Python 2.7 and 3.4), as well as on Linux (Python 2.7 and 3.4). Thanks!

@matysek matysek closed this as completed Oct 13, 2015
@soupault
Copy link

Fixed for me also (Win7, Anaconda, Python 3.4).

@dloman
Copy link

dloman commented Oct 15, 2015

Fixed for me as well 👍

@ProfPh
Copy link

ProfPh commented Nov 15, 2015

The commits didn't work for me but the latest dev version did fix it!

@joedborg
Copy link

Confirmed the dev version (3.1dev0) is the winner.

@matysek matysek removed the state:need info Need more information for solve or help. label Dec 13, 2015
@MajjigaDeepak
Copy link

After including pandas.lib in dist folder & adding in binary in spec file.i executed the app but still same error.Should I do any build after this change?

@matysek
Copy link
Member

matysek commented Dec 23, 2015

@MajjigaDeepak if you have any issues please create a new report with exact description technical details.

@pyinstaller pyinstaller locked and limited conversation to collaborators Dec 23, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests