hiroaki
hiroaki

Reputation: 11

Import error: Error importing scipy

    import pandas
    Traceback (most recent call last):
    File "", line 1, in
    File "/Users/.../anaconda/lib/python2.7/site-packages/pandas/init.py", line 37 , in
import pandas.core.config_init
     File "/Users/.../anaconda/lib/python2.7/site-packages/pandas/core/config_init.py", line 18, in
    from pandas.formats.format import detect_console_encoding
    File "/Users/.../anaconda/lib/python2.7/site-packages/pandas/formats/format.py", l ine 16, in
    from pandas.io.common import _get_handle, UnicodeWriter, _expand_user
    File "/Users/.../anaconda/lib/python2.7/site-packages/pandas/io/common.py", line 5 , in
     import csv
     File "csv.py", line 10, in
     field_size_limit, \
     File "csv_test.py", line 4, in
     from scipy import stats
     File "scipy/init.py", line 103, in
    raise ImportError(msg)
    ImportError: Error importing scipy: you cannot import scipy while
    being in scipy source directory; please exit the scipy source
     tree first, and relaunch your python intepreter.

I tried to import pandas by invoking python from bash. Before doing so,I used 'which python' command to make sure which python I'm using. It interacted to me saying "/Users/...(Usersname)/anaconda/bin/python". But when I imported pandas from IPython of anaconda's distribution, successfully imported. for the record,I added csv_test.py module by hand. guess this module is doing something wrong? it just imports scipy.stats and matplotlib.pyplot. So I hope it is not affecting any other module. seems something seriously wrong is going on here,judging from Error sentence..

Upvotes: 0

Views: 549

Answers (1)

Lorenzo Gatti
Lorenzo Gatti

Reputation: 1270

The csv_test.py file you have "added by hand" tries to import scipy; as the error message says, don't do that.

You can probably place your test code in a private location, without messing with the scipy installation directory.

I suggest uninstalling and reinstalling at least pandas and scipy, possibly everything, to eliminate intentional and unintentional alterations.

Upvotes: 1

Related Questions