0

I am using Python 3.4.0. I am going to assume that the numpy module should work, as this is one of the newer versions of python. However, anything I do with numpy will result in a syntax error. Forexample this code here:

    import numpy
    list1=[1,3,2,6,9]
    list2=numpy.mean(list1)
    print(list2)

And then I get:

    Traceback (most recent call last):
      File "/home/yichen/Desktop/python/numpy test.py", line 1, in <module>
        import numpy
    ImportError: No module named 'numpy'

Is this just a problem with my computer or what?

2
  • 2
    Probably the numpy module is not installed on your system. Commented Mar 16, 2015 at 20:58
  • How should I install it then? Commented Mar 16, 2015 at 21:00

1 Answer 1

1

It looks like numpy is not installed on your system. Assuming that you have the pip script installed with your python, you can perform following command to install it:

pip install numpy

or

pip3.4 install numpy

Or, depending on your distribution, it might come as a package named like python-numpy with your package manager.

Sign up to request clarification or add additional context in comments.

10 Comments

In general, I'd suggest trying your package manager first over pip. It avoids the compilation step and for numpy, thats extensive.
Yes, it is also managed better, so the system would be cleaner. But the version in the repo is often outdated. So one should consider their preferences..
Fedora seems to update their repos quite quickly, but I can't speak to others, so point well-taken.
Just checked on my system (Fedora :) )..The repo has version v1.8.2, pip has v1.9.2. Well, not critical at all, unless there are some bugs..
In ubuntu it should be something like apt-get install python-numpy or similar. I don't have ubuntu box accessible.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.