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

Astropy 2.0 Tables Not Importing in Python 2.7 #6358

Closed
dborncamp opened this issue Jul 10, 2017 · 11 comments
Closed

Astropy 2.0 Tables Not Importing in Python 2.7 #6358

dborncamp opened this issue Jul 10, 2017 · 11 comments

Comments

@dborncamp
Copy link

When I try to import astropy tables using the current anaconda build (using numpy 1.13.1) I get a numpy error. But when I downgrade to numpy 1.12.1 it works. Seems like issue with numpy 1.13.

bash 34% conda create -n astroTest071017 astropy
Fetching package metadata .........
Solving package specifications: ..........

Package plan for installation in environment /Users/dborncamp/miniconda2/envs/astroTest071017:

The following NEW packages will be INSTALLED:

    astropy:    2.0-np113py27_0
    mkl:        2017.0.3-0
    numpy:      1.13.1-py27_0
    openssl:    1.0.2l-0
    pip:        9.0.1-py27_1
    py:         1.4.34-py27_0
    pytest:     3.1.2-py27_0
    python:     2.7.13-0
    readline:   6.2-2
    setuptools: 27.2.0-py27_0
    sqlite:     3.13.0-0
    tk:         8.5.18-0
    wheel:      0.29.0-py27_0
    zlib:       1.2.8-3

Proceed ([y]/n)? y

Linking packages ...
[      COMPLETE      ]|#########################################################################################################################################################################| 100%
#
# To activate this environment, use:
# > source activate astroTest071017
#
# To deactivate this environment, use:
# > source deactivate astroTest071017
#

bash 35% source activate astroTest071017
(astroTest071017) bash 36% python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> from astropy.table import Table
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/table/__init__.py", line 44, in <module>
    from .column import Column, MaskedColumn, StringTruncateWarning, ColumnInfo
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/table/column.py", line 30, in <module>
    from . import groups
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/table/groups.py", line 11, in <module>
    from .index import get_index
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/table/index.py", line 42, in <module>
    from ..time import Time
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/time/__init__.py", line 2, in <module>
    from .formats import *
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/time/formats.py", line 15, in <module>
    from .. import _erfa as erfa
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/_erfa/__init__.py", line 4, in <module>
    from .core import *
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/_erfa/core.py", line 42, in <module>
    from . import _core
ImportError: numpy.core.multiarray failed to import
>>> exit()

Try again with older Numpy:

bash 40% conda create -n astroTest071017 astropy numpy=1.12.1
Fetching package metadata .........
Solving package specifications: ..........

Package plan for installation in environment /Users/dborncamp/miniconda2/envs/astroTest071017:

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    numpy-1.12.1               |           py27_0         3.4 MB
    astropy-2.0                |      np112py27_0         6.3 MB
    ------------------------------------------------------------
                                           Total:         9.7 MB

The following NEW packages will be INSTALLED:

    astropy:    2.0-np112py27_0
    mkl:        2017.0.3-0
    numpy:      1.12.1-py27_0
    openssl:    1.0.2l-0
    pip:        9.0.1-py27_1
    py:         1.4.34-py27_0
    pytest:     3.1.2-py27_0
    python:     2.7.13-0
    readline:   6.2-2
    setuptools: 27.2.0-py27_0
    sqlite:     3.13.0-0
    tk:         8.5.18-0
    wheel:      0.29.0-py27_0
    zlib:       1.2.8-3

Proceed ([y]/n)? y

Fetching packages ...
numpy-1.12.1-p 100% |######################################################################################################################################################| Time: 0:00:00  28.68 MB/s
astropy-2.0-np 100% |######################################################################################################################################################| Time: 0:00:00  32.90 MB/s
Extracting packages ...
[      COMPLETE      ]|#########################################################################################################################################################################| 100%
Linking packages ...
[      COMPLETE      ]|#########################################################################################################################################################################| 100%
#
# To activate this environment, use:
# > source activate astroTest071017
#
# To deactivate this environment, use:
# > source deactivate astroTest071017
#

bash 41% source activate astroTest071017
(astroTest071017) bash 42% python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> from astropy.table import Table
>>> tab = Table()
>>> tab
<Table length=0>
<No columns>
@MSeifert04
Copy link
Contributor

Does the error also occur if you just try to import numpy?

@dborncamp
Copy link
Author

It does not happen if I just import numpy or from numpy.core import multiarray.

(astroTest071017) bash 56% python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy
>>> from astropy.table import Table
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/table/__init__.py", line 44, in <module>
    from .column import Column, MaskedColumn, StringTruncateWarning, ColumnInfo
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/table/column.py", line 30, in <module>
    from . import groups
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/table/groups.py", line 11, in <module>
    from .index import get_index
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/table/index.py", line 42, in <module>
    from ..time import Time
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/time/__init__.py", line 2, in <module>
    from .formats import *
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/time/formats.py", line 15, in <module>
    from .. import _erfa as erfa
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/_erfa/__init__.py", line 4, in <module>
    from .core import *
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/_erfa/core.py", line 42, in <module>
    from . import _core
ImportError: numpy.core.multiarray failed to import
>>> from numpy.core import multiarray
>>>

@MSeifert04
Copy link
Contributor

ok, I can't replicate this locally.

Maybe something went wrong with the conda package for mac, numpy=1.13 and python 2.7. It works on windows and on my VM Linux.

@pllim
Copy link
Member

pllim commented Jul 11, 2017

Hmm a search in the Internet gave me tensorflow/tensorflow#559. Do you have an older Numpy version installed somewhere in your PYTHONPATH?

@astrofrog
Copy link
Member

astrofrog commented Jul 11, 2017

@dborncamp can you run conda env export and let us know the output? (this will show if other numpies are present)

@dborncamp
Copy link
Author

I don't think there are multiple version of numpy floating around...

(astroTest071017) bash 70% conda env export
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
name: astroTest071017
channels: !!python/tuple
- !!python/unicode
  'http://ssb.stsci.edu/astroconda'
- !!python/unicode
  'defaults'
dependencies:
- astropy=2.0=np113py27_0
- mkl=2017.0.3=0
- numpy=1.13.1=py27_0
- openssl=1.0.2l=0
- pip=9.0.1=py27_1
- py=1.4.34=py27_0
- pytest=3.1.2=py27_0
- python=2.7.13=0
- readline=6.2=2
- setuptools=27.2.0=py27_0
- sqlite=3.13.0=0
- tk=8.5.18=0
- wheel=0.29.0=py27_0
- zlib=1.2.8=3
- pip:
  - common==0.3.2
  - nose==1.3.7
prefix: /Users/dborncamp/miniconda2/envs/astroTest071017

@funbaker
Copy link
Contributor

Try
print(numpy)
with the direct import and in _erfa/core.py and compare the module paths.

@dborncamp
Copy link
Author

Looking at the paths it looks like it is pulling a numpy that is not within my conda environment and is not the version found in the conda env. Not sure why it is picking that version up since it is not in my PYTHONPATH and the conda version exists and is pointed to first in my path.

(astroTest071017) bash 3% python
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:05:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy
>>> print numpy
<module 'numpy' from '/usr/local/lib/python2.7/site-packages/numpy/__init__.pyc'>
>>> from astropy import _erfa
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/_erfa/__init__.py", line 4, in <module>
    from .core import *
  File "/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/astropy/_erfa/core.py", line 42, in <module>
    from . import _core
ImportError: numpy.core.multiarray failed to import
>>> from numpy.core import multiarray
>>> print multiarray
<module 'numpy.core.multiarray' from '/usr/local/lib/python2.7/site-packages/numpy/core/multiarray.so'>
>>> numpy.__version__
'1.12.1'
>>> exit()
(astroTest071017) bash 3% echo $PYTHONPATH
/usr/local/opt/opencv3/lib/python2.7/site-packages/:/Users/dborncamp/common/common/:/user/dborncamp/pylib/:
(astroTest071017) bash 4% ls /Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/numpy/core/multiarray.so
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/numpy/core/multiarray.so

@funbaker
Copy link
Contributor

Whats the value of sys.path? Documentation mentions a installation depended default additional to PYTHONPATH, but i don't know conda well enough. virtualenv has a --system-site-packages option, maybe it's related to that?

@dborncamp
Copy link
Author

Not sure why the wrong version is even in my path but it appears to be loaded first. Perhaps this is an issue with conda? Maybe I have an older version...

>>> for p in sys.path:
...    print p
...

/usr/local/opt/opencv3/lib/python2.7/site-packages
/Users/dborncamp/common/common
/user/dborncamp/pylib
/Users/dborncamp
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python27.zip
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/plat-darwin
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/plat-mac
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/plat-mac/lib-scriptpackages
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/lib-tk
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/lib-old
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/lib-dynload
/Users/dborncamp/.local/lib/python2.7/site-packages
/usr/local/lib/python2.7/site-packages
/usr/local/Cellar/numpy/1.12.1/libexec/nose/lib/python2.7/site-packages
/usr/local/opt/llvm/lib/python2.7/site-packages
/usr/local/lib/python2.7/site-packages/gtk-2.0
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages
/Users/dborncamp/miniconda2/envs/astroTest071017/lib/python2.7/site-packages/setuptools-27.2.0-py2.7.egg

@dborncamp
Copy link
Author

Updating my version of conda fixed it

(astroTest071017) bash 15% source deactivate
bash 16% conda update conda

Reinstall and it worked:

bash 19% conda create -n astroTest071017 astropy
Fetching package metadata ...........
Solving package specifications: .

Package plan for installation in environment /Users/dborncamp/miniconda2/envs/astroTest071017:

The following NEW packages will be INSTALLED:

    astropy:    2.0-np113py27_0
    mkl:        2017.0.3-0
    numpy:      1.13.1-py27_0
    openssl:    1.0.2l-0
    pip:        9.0.1-py27_1
    py:         1.4.34-py27_0
    pytest:     3.1.2-py27_0
    python:     2.7.13-0
    readline:   6.2-2
    setuptools: 27.2.0-py27_0
    sqlite:     3.13.0-0
    tk:         8.5.18-0
    wheel:      0.29.0-py27_0
    zlib:       1.2.8-3

Proceed ([y]/n)? y

setuptools-27. 100% |################################| Time: 0:00:00  12.55 MB/s
wheel-0.29.0-p 100% |################################| Time: 0:00:00  20.73 MB/s
#
# To activate this environment, use:
# > source activate astroTest071017
#
# To deactivate an active environment, use:
# > source deactivate
#

bash 20% python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 26 2016, 12:10:39)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from astropy.table import Table
>>> tab = Table()
>>> tab
<Table length=0>
<No columns>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants