Problem with numpy

52 views
Skip to first unread message

23p...@cua.edu

unread,
Mar 22, 2018, 1:12:51 PM3/22/18
to SunPy
Hi,

I am a new user of Sunpy. I just installed Anaconda 3.6.4. When I run ipython on the command prompt, a version of Anaconda runs perfectly. However when I type import numpy as np, I get the following error message:



In [1]: import numpy as np

---------------------------------------------------------------------------

ImportError                               Traceback (most recent call last)

<ipython-input-1-0aa0b027fcb6> in <module>()

----> 1 import numpy as np


/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.py in <module>()

    151         return loader(*packages, **options)

    152 

--> 153     from . import add_newdocs

    154     __all__ = ['add_newdocs', 'ModuleDeprecationWarning']

    155 


/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/add_newdocs.py in <module>()

     11 from __future__ import division, absolute_import, print_function

     12 

---> 13 from numpy.lib import add_newdoc

     14 

     15 ###############################################################################


/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/__init__.py in <module>()

      6 from numpy.version import version as __version__

      7 

----> 8 from .type_check import *

      9 from .index_tricks import *

     10 from .function_base import *


/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/type_check.py in <module>()

      9            'common_type']

     10 

---> 11 import numpy.core.numeric as _nx

     12 from numpy.core.numeric import asarray, asanyarray, array, isnan, \

     13                 obj2sctype, zeros


/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/__init__.py in <module>()

      4 from numpy.version import version as __version__

      5 

----> 6 from . import multiarray

      7 from . import umath

      8 from . import _internal # for freeze programs


ImportError: dlopen(/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type

  Referenced from: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/multiarray.so

  Expected in: flat namespace

 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/multiarray.so




I and Jack Ireland tried a few things but could not get this problem to be fixed. I would appreciate if anyone could help.


Thanks. 

Vishnunarayan K. I.

unread,
Mar 22, 2018, 1:19:50 PM3/22/18
to SunPy
Even though you said you installed anaconda 3.6.4, you seem to be using python 2.7 which must be your system python. Make sure you have activated conda environment

Stuart Mumford

unread,
Mar 23, 2018, 7:44:03 AM3/23/18
to su...@googlegroups.com

I agree, it looks like you are still using system python rather than anaconda. check that your $PATH is correct and has your anaconda installation in it.


Stuart

--
You received this message because you are subscribed to the Google Groups "SunPy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sunpy+un...@googlegroups.com.
To post to this group, send email to su...@googlegroups.com.
Visit this group at https://groups.google.com/group/sunpy.
For more options, visit https://groups.google.com/d/optout.

23p...@cua.edu

unread,
Mar 25, 2018, 8:18:36 PM3/25/18
to SunPy
Thanks for your replies. However, I still have not been able to get numpy or scipy or any other package for that matter. My .bash_profile has the following content:

# added by Anaconda3 5.1.0 installer
export PATH="/Users/cua-user/anaconda3/bin:$PATH"


#export PYTHONPATH=/Users/cua-user/my_installs/lib/python
#export PYTHONPATH=/usr/bin/python

#ur_setup() {
#    eval `/Users/cua-user/.ureka/ur_setup -sh $*`
#}
#ur_forget() {
#    eval `/Users/cua-user/.ureka/ur_forget -sh $*`
#}

# added by Anaconda3 5.1.0 installer
#export PATH="/anaconda3/bin:$PATH"


And my .bashrc has the following:


alias ll='ls -l'
PATH=/usr/local/bin:/usr/sbin:/sbin:/opt/X11/bin:/opt/X11/bin:/opt/include/:

ur_setup() {
    eval `/Users/cua-user/.ureka/ur_setup -sh $*`
}
ur_forget() {
    eval `/Users/cua-user/.ureka/ur_forget -sh $*`
}

My echo $PATH returns the following:

/Users/cua-user/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin


Like I mentioned, when I run python, Anaconda version runs but when I try to run, for instance, numpy, I get the aforementioned error. I will appreciate your input. Thanks.

23p...@cua.edu

unread,
Mar 25, 2018, 8:30:52 PM3/25/18
to SunPy
Also when I try to test whether the installed version of sunpy is installed properly, I get the following:

localadmins-MacBook-Pro:~ cua-user$ ipython

Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33) 

Type 'copyright', 'credits' or 'license' for more information

IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.


In [1]: import sunpy


In [2]: sunpy.self_test(online=False)

---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

<ipython-input-2-3f87d9c47c53> in <module>()

----> 1 sunpy.self_test(online=False)


AttributeError: module 'sunpy' has no attribute 'self_test'


In [3]: 


I would appreciate your input.


Thanks

Niraj

Kolja

unread,
Mar 27, 2018, 9:28:37 AM3/27/18
to su...@googlegroups.com
Hi Niraj,

are you sure that you installed SunPy? Your error message looks like you
did not install any SunPy package.

The reason why "import sunpy" works in your case is probably caused by a
sunpy subdirectory in your home directory, which is then imported as a
namespace package by Python 3 because no regular "sunpy" package is
installed.

Cheers,
Kolja


On 03/26/2018 02:30 AM, 23p...@cua.edu wrote:
> Also when I try to test whether the installed version of sunpy is
> installed properly, I get the following:
>
> localadmins-MacBook-Pro:~ cua-user$ ipython
>
> Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
>
> Type 'copyright', 'credits' or 'license' for more information
>
> IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
>
>
> In [*1*]: *import**sunpy*
>
>
> In [*2*]: sunpy.self_test(online=*False*)
>
> ---------------------------------------------------------------------------
>
> AttributeErrorTraceback (most recent call last)
>
> <ipython-input-2-3f87d9c47c53>in <module>()
>
> ----> 1sunpy.self_test(online=False)
>
>
> AttributeError: module 'sunpy' has no attribute 'self_test'
>
>
> In [*3*]:
>> In [*1*]: *import**numpy**as**np*
>>
>> ---------------------------------------------------------------------------
>>
>> ImportErrorTraceback (most recent call last)
>>
>> <ipython-input-1-0aa0b027fcb6>in <module>()
>>
>> ----> 1importnumpy asnp
>>
>>
>> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/__init__.pyin
>> <module>()
>>
>> *151*returnloader(*packages,**options)
>>
>> *152*
>>
>> --> 153from.importadd_newdocs
>>
>> *154*__all__ =['add_newdocs','ModuleDeprecationWarning']
>>
>> *155*
>>
>>
>> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/add_newdocs.pyin
>> <module>()
>>
>> *11*from__future__
>> importdivision,absolute_import,print_function
>>
>> *12*
>>
>> ---> 13fromnumpy.lib importadd_newdoc
>>
>> *14*
>>
>> *15*###############################################################################
>>
>>
>> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/__init__.pyin
>> <module>()
>>
>> *6*fromnumpy.version importversion as__version__
>>
>> *7*
>>
>> ----> 8from.type_check import*
>>
>> *9*from.index_tricks import*
>>
>> *10*from.function_base import*
>>
>>
>> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/lib/type_check.pyin
>> <module>()
>>
>> *9*'common_type']
>>
>> *10*
>>
>> ---> 11importnumpy.core.numeric as_nx
>>
>> *12*fromnumpy.core.numeric
>> importasarray,asanyarray,array,isnan,\
>>
>> *13*obj2sctype,zeros
>>
>>
>> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/__init__.pyin
>> <module>()
>>
>> *4*fromnumpy.version importversion as__version__
>>
>> *5*
>>
>> ----> 6from.importmultiarray
>>
>> *7*from.importumath
>>
>> *8*from.import_internal # for freeze programs

23p...@cua.edu

unread,
Mar 27, 2018, 11:50:16 AM3/27/18
to SunPy
Hi Kolja,

After your reply, I installed sunpy. When I run to test whether sunpy is okay or not, I get the following messages:

In [1]: import sunpy

---------------------------------------------------------------------------

ImportError                               Traceback (most recent call last)

<ipython-input-1-1a62dedba559> in <module>()

----> 1 import sunpy


~/anaconda3/lib/python3.6/site-packages/sunpy/__init__.py in <module>()

     22     __githash__ = ''

     23 

---> 24 from sunpy.util.config import load_config, print_config

     25 from sunpy.util import system_info

     26 from sunpy.tests import main as self_test


~/anaconda3/lib/python3.6/site-packages/sunpy/util/__init__.py in <module>()

      4 from sunpy.util.exceptions import *

      5 from sunpy.util.decorators import *

----> 6 from sunpy.util.util import *

      7 from sunpy.util.sysinfo import *

      8 from sunpy.util.metadata import MetaDict


~/anaconda3/lib/python3.6/site-packages/sunpy/util/util.py in <module>()

      8 from itertools import count

      9 

---> 10 import numpy as np

     11 

     12 from sunpy.extern import six

In [2]: 



Any help would be appreciated.


Sincerely,

Niraj

Kolja

unread,
Mar 27, 2018, 12:37:31 PM3/27/18
to su...@googlegroups.com
Hi Niraj,

There is still happening something weird with your Python installation,
which does not looks like it has anything to do with SunPy. Your error
traceback shows that a non-Anaconda Python 2.7 version of NumPy is
imported instead of the Python 3.6 version that comes with Anaconda.

You will probably also get a similar error when you just start IPython
and do an "import numpy". You need to fix this problem first, before
trying to use SunPy.

You should check if the PYTHONPATH environment variable is set using

echo $PYTHONPATH

In case it is not empty, use "unset PYTHONPATH" to clear it, start
IPython from this shell, and try "import numpy" again. It might be also
helpful to check what is actually in your Python path, using for example:

python -c "import sys; print(sys.version); print(sys.path)"

or by printing sys.path in your IPython session.

Cheers,
Kolja


On 03/27/2018 05:50 PM, 23p...@cua.edu wrote:
> Hi Kolja,
>
> After your reply, I installed sunpy. When I run to test whether sunpy is
> okay or not, I get the following messages:
>
> In [*1*]: *import**sunpy*
>
> ---------------------------------------------------------------------------
>
> ImportErrorTraceback (most recent call last)
>
> <ipython-input-1-1a62dedba559>in <module>()
>
> ----> 1importsunpy
>
>
> ~/anaconda3/lib/python3.6/site-packages/sunpy/__init__.pyin <module>()
>
> *22*__githash__ =''
>
> *23*
>
> ---> 24fromsunpy.util.config importload_config,print_config
>
> *25*fromsunpy.util importsystem_info
>
> *26*fromsunpy.tests importmain asself_test
>
>
> ~/anaconda3/lib/python3.6/site-packages/sunpy/util/__init__.pyin <module>()
>
> *4*fromsunpy.util.exceptions import*
>
> *5*fromsunpy.util.decorators import*
>
> ----> 6fromsunpy.util.util import*
>
> *7*fromsunpy.util.sysinfo import*
>
> *8*fromsunpy.util.metadata importMetaDict
>
>
> ~/anaconda3/lib/python3.6/site-packages/sunpy/util/util.pyin <module>()
>
> *8*fromitertools importcount
>
> *9*
>
> ---> 10importnumpy asnp
>
> *11*
>
> *12*fromsunpy.extern importsix
> *8*from.import_internal # for freeze programs
>
>
> ImportError:
> dlopen(/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/multiarray.so,
> 2): Symbol not found: _PyBuffer_Type
>
> Referenced from:
> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/multiarray.so
>
> Expected in: flat namespace
>
> in
> /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/core/multiarray.so
>
>
> In [*2*]:
>
>
>
> Any help would be appreciated.
>
>
> Sincerely,
>
> Niraj
>
>
> On Thursday, March 22, 2018 at 1:12:51 PM UTC-4, 23p...@cua.edu wrote:
>
> Hi,
>
> I am a new user of Sunpy. I just installed Anaconda 3.6.4. When I
> run ipython on the command prompt, a version of Anaconda runs
> perfectly. However when I type import numpy as np, I get the
> following error message:
>
>
>
> In [*1*]: *import**numpy**as**np*
>
> ---------------------------------------------------------------------------
>
> ImportErrorTraceback (most recent call last)
>
> <ipython-input-1-0aa0b027fcb6>in <module>()
>
> *8*from.import_internal # for freeze programs

23p...@cua.edu

unread,
Mar 27, 2018, 5:16:17 PM3/27/18
to SunPy
Hi Kolja,

You were correct in saying that import numpy was giving the same problem. After I did "unset PYTHONPATH" they work (both sunpy and numpy). But do I have to do this ("unset PYTHONPATH") on a new terminal every time before I run ipython, as the PYTHONPATH keeps reverting to my old setting as soon as I restart the terminal. In other words is there a way to change or delete (whichever might be appropriate) the PYTHONPATH?

Thanks for your help.

Nora 

23p...@cua.edu

unread,
Mar 27, 2018, 5:40:31 PM3/27/18
to SunPy
Hi Kolja and everyone,

I fixed the issue. Everything seems to be working well now. 

Sincerely,
Niraj

23p...@cua.edu

unread,
Mar 27, 2018, 5:51:26 PM3/27/18
to SunPy
Thanks to your help.

Niraj
Reply all
Reply to author
Forward
0 new messages