I tried to install numpy, but whenever I start my program, I get these messages.
Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.
Traceback (most recent call last):
File "C:\Python34\numpy\__init__.py", line 155, in <module>
from numpy.__config__ import show as show_config
ImportError: No module named 'numpy.__config__'
I don't understand what it means by not importing numpy from it's source directory. Where am I supposed to import it from instead?
The error means just what it says. You are probably in C:\Python34
or C:\Python34\numpy
when you run python
on the command line. Switch to another directory (such as C:\
) and run python
, then try import numpy
and see what happens.
From your comments, it looks like you didn't properly install numpy
, just unzipped it into your C:\Python34
directory. The easiest way to install this modules is to visit Christoph Gohlke's Python Extension Packages for Windows Repository and go down to numpy
. Download the cp34
file for your version of Python (either 32- or 64-bit). Then, on the command line, switch to your Downloads directory and run, for example
pip install numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl
(if you downloaded the 64-bit version) and it should install quite nicely. If you get a Command not found
error for pip
, make sure you add C:\Python34\Scripts
to your PATH environment variable. Once you do that, restart the command line and it should work perfectly.
Gohlke has a ton of pre-compiled modules for Python, mostly relating to scientific computing, and I always check there first before installing from PyPI with pip
.