ubuntu 13.04 python2.7 cannot import matplotlib and other module


i have just installed matplotlib to generate some plots. but this module cannot be imported in python interpreter. although it can be imported in ipython, when i use ipython to execute those examples. it didn't show anything...

besides that, i also can't use idle.

   
  ** IDLE can't import Tkinter. Your Python may not be configured for Tk. **
 

my os is ubuntu 13.04 and the default python version is 3.0. But i install python 2.7 manually.

is there anything wrong with my python configuration.

my python path is

   
  ['', '/usr/local/lib/python27.zip', '/usr/local/lib/python2.7', '/usr/local/lib/python2.7/plat-linux2', '/usr/local/lib/python2.7/lib-tk', '/usr/local/lib/python2.7/lib-old', '/usr/local/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages']
 

this has bothered me for almost a day, thank you in advance!

i just find that only when i start python in terminal, those module cannot be imported!

the sys.path in ipython is

   
  ['',
  
'/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/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol',
'/usr/lib/python2.7/dist-packages/IPython/extensions']

but after i add those path to PYTHONPATH, it still cannot work.

   
  ImportError: numpy/core/multiarray.so: undefined symbol: PyUnicodeUCS4_AsUnicodeEscapeString
 

so how can i overwrite the pythonpath??

python matplotlib

秘刃十六夜 11 years, 6 months ago

抱歉,先是在stackoverflow上问的,直接粘贴过来了...
原来是ubuntu上原来是python2.7.4和.3.3,我自己又装了2.7.5...
有的pythonpath里面没包括全部路径...
卸载python把电脑折腾坏了..最后重装了...

Mkukon answered 11 years, 6 months ago

Your Answer