importing xarray doesn't work with ipython

importing xarray doesn't work with ipython

I find this very strange. I have installed intel python using

conda create -c intel -n intelpython3 python=3 intelpython3_core

I activate the environment, and then install xarray using conda. Import of xarray works fine in python, but not in ipython or jupyter notebook. I included my basic work flow. This seems to be specific to the xarray package, for example the dependency pandas which I also installed at the same time imports just fine in both ipython and python.

Any thoughts are appreciated! Thanks

(intelpython3) bash-4.2$ python
Python 3.5.3 |Intel Corporation| (default, Apr 27 2017, 18:08:47)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out:
>>> import xarray

Works fine. This does not:

(intelpython3) bash-4.2$ ipython
Python 3.5.3 |Intel Corporation| (default, Apr 27 2017, 18:08:47)
Type "copyright", "credits" or "license" for more information.

IPython 5.3.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import xarray
ImportError                               Traceback (most recent call last)
<ipython-input-1-cb9924ede87d> in <module>()
----> 1 import xarray

ImportError: No module named 'xarray'


Thread Topic: 

Bug Report
3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

Hi Edward,

If you create a conda-env with "python=3 intelpython3_core" you get the following packages installed (as is the output of conda list from the activated environment) :

icc_rt                    16.0.3                  intel_6  [intel]  intel
intelpython               2017.0.3                      4    intel
intelpython3_core         2017.0.3                      3    intel
mkl                       2017.0.3                intel_6  [intel]  intel
numpy                     1.12.1             py35_intel_8  [intel]  intel
openmp                    2017.0.3                intel_8    intel
openssl                   1.0.2k                  intel_3  [intel]  intel
pip                       9.0.1              py35_intel_0  [intel]  intel
python                    3.5.3                   intel_1  [intel]  intel
pyyaml                    3.12               py35_intel_1  [intel]  intel
scipy                     0.19.0          np112py35_intel_2  [intel]  intel
setuptools                27.2.0             py35_intel_0  [intel]  intel
sqlite                    3.13.0                 intel_14  [intel]  intel
tbb                       2017.0.6          py35_intel_15  [intel]  intel
tcl                       8.6.4                  intel_16  [intel]  intel
tk                        8.6.4                  intel_26  [intel]  intel
wheel                     0.29.0             py35_intel_5  [intel]  intel
xz                        5.2.2                  intel_15  [intel]  intel
yaml                      0.1.6                  intel_10  [intel]  intel
zlib                      1.2.11                  intel_2  [intel]  intel

As you don't have IPython installed in your activated environment, you should conda install that into your environment (conda install ipython)
From the activated environment, you can install xarray with conda install xarray

To verify that this has worked you can run the following from your activated environment:

  1. python -c "import xarray"
  2. ipython -c "import xarray"

If neither print anything to STDOUT, you're good to go. Also, if you want to install Jupyter Notebook as well, you can do so from your activated environment.


That worked. Thank you for your help. I guess the issue lay with my cursory knowledge of conda environments, and wasn't necessarily intel python related. I appreciate your taking the time to answer.

Leave a Comment

Please sign in to add a comment. Not a member? Join today