1

I'm currently writing some code for the Pandas core and I'm wondering if my workflow is correct.

As the Travis CI instance tests against different versions of Python, I have conda set up to switch between the different versions locally so I can see if the test suite passes or fails.

But every time I switch between environments I get:

ERROR: Failure: ImportError (C extension: libpython2.6.so.1.0: cannot open shared object file: No such file or directory 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.)

and when I do python setup.py build_ext --inplace I get:

/home/some_user/anaconda/lib/python2.7/site-packages/setuptools-17.1.1-py2.7.egg/setuptools/dist.py:294: UserWarning: The version specified ('0.16.2-134-g84d6eba') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
running build_ext
skipping 'pandas/index.c' Cython extension (up-to-date)
skipping 'pandas/src/period.c' Cython extension (up-to-date)
skipping 'pandas/algos.c' Cython extension (up-to-date)
skipping 'pandas/lib.c' Cython extension (up-to-date)
skipping 'pandas/tslib.c' Cython extension (up-to-date)
skipping 'pandas/parser.c' Cython extension (up-to-date)
skipping 'pandas/hashtable.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)

So, as per @Jeff's comment to this question, I rebuild the extensions using:

python setup.py build_ext --inplace --force

And things work fine. But the build takes a good few minutes to run, and it feels like I'm doing something wrong. (It certainly doesn't mention having to force a rebuild in the Contributing to Pandas guide.

So am I doing something wrong, or is this just the way it works?

Community
  • 1
  • 1
LondonRob
  • 73,083
  • 37
  • 144
  • 201

1 Answers1

2

You cannot build multiple versions in the same space. You need to do one of these:

  • put the cloned directory inside of the conda directory itself. E.g. if you have pandas2.6, then you can (your path may vary if you have miniconda/anaconda installed), to ~/minicona/envs/pandas2.6 then clone pandas there and python setup.py build_ext --inplace and access locally

  • use python setup.py build. If your clone directory is ~/pandas. This puts the builds for different versions in ~/pandas/builds/...... The downside of this is you actually have to path things to run them, e.g. nosetests ~/pandas/builds/....../pandas/tests/test_series.py for example. Further you to rebuild each time you want to make a change (but since the c-extensions are already built this is usually very fast).

Jeff
  • 125,376
  • 21
  • 220
  • 187