9

Try to do a development build with 3.4 (have previously managed in 2.7). Python is just an anaconda installation on osx10.10. I can get

I:

  • git cloned pandas
  • ran python setup.py build_ext --inplace (got no errors)
  • ran python setup.py develop.

But when I try and import pandas I get:

import pandas as pd
Traceback (most recent call last):

  File "<ipython-input-2-af55e7023913>", line 1, in <module>
    import pandas as pd

  File "/Users/Nick/github/pandas/pandas/__init__.py", line 13, in <module>
    "extensions first.".format(module))

ImportError: C extension: 'hashtable' 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.

Note that when I do build_ext I get the following (apparently fine) output:

pandas(master)$python setup.py build_ext --inplace

running build_ext
skipping 'pandas/index.c' Cython extension (up-to-date)
skipping 'pandas/lib.c' Cython extension (up-to-date)
skipping 'pandas/parser.c' Cython extension (up-to-date)
skipping 'pandas/src/period.c' Cython extension (up-to-date)
skipping 'pandas/hashtable.c' Cython extension (up-to-date)
skipping 'pandas/algos.c' Cython extension (up-to-date)
skipping 'pandas/tslib.c' Cython extension (up-to-date)
skipping 'pandas/src/sparse.c' Cython extension (up-to-date)
skipping 'pandas/src/testing.c' Cython extension (up-to-date)
skipping 'pandas/msgpack.cpp' Cython extension (up-to-date)

Further, I can get pandas installed if I run conda install pandas, but would really like a development environment for code development.

Similar to this, which looked unsolved and this

Community
  • 1
  • 1
nick_eu
  • 3,541
  • 5
  • 24
  • 38
  • 2
    Have you tried `python setup.py build_ext --inplace --force`? – chrisb Jul 18 '15 at 22:22
  • @chrisb you are my hero. Thanks! post as an answer and I'll select. – nick_eu Jul 19 '15 at 03:24
  • A small note here: Why do you install `pandas` via `setup.py` instead of using `conda`? The really cool thing about anaconda is that it ships already compiled versions of various packages of the stack of scientific software. So when using `conda install` you should never run into these kind of issues. – cel Jul 19 '15 at 08:31
  • 2
    @cel that's great if you just want to _use_ a package, but if you want to modify the package (add features, etc.), a pre-compiled package isn't very useful. When you make a development build, python automatically integrates any changes the user (me) has made to the package code every time it imports. This makes it easy to test new code. – nick_eu Jul 19 '15 at 14:43
  • pls read the contributing docs [here](http://pandas.pydata.org/pandas-docs/stable/contributing.html); generally it is useful to use conda to create your build environment itself; the reason you need --force is that you have another process open with Python – Jeff Jul 19 '15 at 16:05
  • ah, ok, thanks @Jeff. – nick_eu Jul 19 '15 at 18:25
  • I have the same problem with python 3.3.2. I tried the flags above, but I keep getting the same `ImportError`. I install from source because I am a user on a hpc cluster and i don't have administrative rights – simona May 03 '16 at 15:39

2 Answers2

8

The answer, due to @chrisb in comments, was to run python setup.py build_ext --inplace --force.

nick_eu
  • 3,541
  • 5
  • 24
  • 38
  • 13
    I have the same problem as you did. Where exactly should I run this code `python setup.py build_ext --inplace --force`? I tried to run this in the pandas folder but it didn't find `setup.py` file. – Daniel Aug 25 '16 at 01:04
1

I solved it reinstalling pandas with this command:

conda install pandas

Everything was working fine, but I installed something using pip and started having problems. This solved it.

neves
  • 33,186
  • 27
  • 159
  • 192