0

I'm trying to install numpy and scipy on python3 using pip3. I want to use MKL, so I've specified as much in ~/.numpy-site.cfg (as suggested here and here):

[mkl]
library_dirs = /opt/intel/mkl/lib/intel64
include_dirs = /opt/intel/mkl/include
mkl_libs = mkl_rt
lapack_libs =
extra_compile_args = -march=native

I then install numpy (successfully) via

$ sudo pip3 install numpy

However, MKL does not show up in the config!

>>> np.show_config()
...
mkl_info:
  NOT AVAILABLE
...

Installing scipy subsequently fails (as expected) with

numpy.distutils.system_info.NotFoundError: no lapack/blas resources found

However, when I install numpy and scipy in a virtualenv on the same machine without changing anything else, MKL is found, and scipy works fine.

My first guess was that sudo was not picking up $HOME, but sudo echo $HOME returns my home directory correctly.

What could be going wrong?

Community
  • 1
  • 1
Praveen
  • 6,872
  • 3
  • 43
  • 62
  • Make sure that the python executable you are using is the same one used in the `pip3` command (for example, `head -n1 \`which pip3\`` should tell you). Or make sure you use the correct pip to install things: `sudo python3 -m pip install numpy` or whatever python executable you use. –  Apr 08 '16 at 04:25
  • any reason you're not using Anaconda? it's not really recommended to install numpy with pip – maxymoo Apr 08 '16 at 04:34
  • You don't happen to have a `site.cfg` lying around somewhere with empty mkl info in it? –  Apr 08 '16 at 05:03
  • @Evert Nope, I'm using the right pip3 - I checked with `which`. I don't have a site.cfg lying around anywhere either... – Praveen Apr 08 '16 at 05:31
  • @maxymoo Not recommended? This is the first I'm hearing of this... But to answer your question, I'm not using Anaconda because I want to custom-link scipy to MKL, not use whatever default ATLAS and BLAS that come with Anaconda. – Praveen Apr 08 '16 at 05:32

1 Answers1

0

It turns out that my guess was indeed correct. sudo isn't using the right $HOME. sudo echo $HOME worked because bash expanded $HOME before calling sudo to run the command.

The following test did the trick though:

# In test.sh
echo "$HOME"

And now I get

$ sudo bash test.sh
/root

which confirms that $HOME is incorrect. It turns out that a bunch of settings had been set in /etc/sudoers (always_set_home and env_reset), which meant that sudo -E bash test.sh had no effect either.

I finally just installed it with

$ sudo HOME=/path/to/my/home pip3 install numpy

which worked.

Praveen
  • 6,872
  • 3
  • 43
  • 62
  • I later discovered that this worked on a RHEL7 machine but not on an Ubuntu 14.04 or 16.04. I still have no clue how to get it to work for Ubuntu. I just ended up installing from source... – Praveen Jun 25 '16 at 05:42