marc
marc

Reputation: 2187

No module named numpy but import works in command line

I know this question has been asked dozens of times, but I still can't find my answer.

I was told that NumPy should be preinstalled on python 2.7 for OS X. To check, I was told to type "import numpy" in the command line in the terminal. No errors appear, suggesting that it's correctly installed. I then do "import matplotlib.pyplot as plot" and I'm told that the module doesn't exist.

NOW, moving out of the terminal to Eclipse, I type the same commands in my scripts, and neither of the packages work.

I'm using PyDev 2.8.2 for Eclipse 2.0.1 and Python 2.7. I also checked that I'm using Python 2.7 by typing "which python", and I can confirm this because the print command doesn't need (). BUT, I did have Python 3 installed at one point.

Thanks!

Upvotes: 0

Views: 1606

Answers (1)

Ivo
Ivo

Reputation: 5420

Here's what I'd suggest:

1) Uninstall all other versions of python apart from the OS X system one. Make sure that none are left on your path with which python which should point to the OS X one.

2) Install brew, which is a package manager for OS X.

3) Use brew to install python - brew install python

4) Read up on brew's support of python here, it's pretty nice.

5) Use pip to install python packages, e.g pip install numpy matplotlib

6) If one of the packages needs a compiler you can install gcc with the brew formula apple-gcc42 or clang with llvm

7) Perhaps try out the new community edition of PyCharm

Upvotes: 1

Related Questions