I am given Ubuntu 14.04 from work even though I always used windows in the past. I installed python-numpy
and python-scipy
from the Ubuntu software center. From the look of it, I think I already install the two packages. I can import them in IPython. However, it seems that IDLE could not find these package.
>>> import numpy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import numpy
ImportError: No module named 'numpy'
Could anyone explain why this is the case and how to fix it, please? Thank you! I am completely new to ubuntu.
As suggested in the comments, I got the following.
IDLE:
['',
'/usr/bin',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-x86_64-linux-gnu',
'/usr/lib/python3.4/lib-dynload',
'/usr/local/lib/python3.4/dist-packages',
'/usr/lib/python3/dist-packages']
IPython:
['',
'/usr/bin',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode',
'/usr/lib/python2.7/dist-packages/IPython/extensions']
Clearly the paths are different. What is more troubling is that they are different version of Python. I must have done something wrong. My intention was to use 3.4 version in fact. I guess I need to add numpy and etc. to this version. How do I do it, please? Thank you!
Your IPython and IDLE editions are based on different major versions of Python (2 and 3 respectively). For your projects you need to use either one or the other for consistency. The relevant package names for the two Python versions are:
Python 2:
idle ipython python-numpy python-scipy
Python 3:
idle3 ipython3 python3-numpy python3-scipy
You can install all of them side by side, but you'll get into trouble if you try to run the same piece of software on both except for the most simple cases.