I’m totally confused with new python 2.7.10.
I've installed python 2.7.10 from tar.xz, which was downloaded from official site. Then I've linked /usr/local/bin/python2.7 with /usr/bin/python2.7 and /usr/bin/python, but when I try to import module, I get ImportError: No module named "module_name". For example:
python -c "import gtk"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named gtk
But if:
cd /usr/lib/python2.7/dist-packages/gtk-2.0/
python -c "import gtk"
We get:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "gtk/__init__.py", line 30, in <module>
import gobject as _gobject
ImportError: No module named gobject
So, gtk module has been imported successfully.
Let's "cd ~" and look at sys.path:
python -c "import sys, pprint; pprint.pprint(sys.path)"
['',
'/usr/local/lib/python2.7/site-packages/setuptools-17.1.1-py2.7.egg',
'/usr/local/lib/python2.7/site-packages/pip-7.1.0.dev0-py2.7.egg',
'/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']
Ok, there is no /usr/lib/python2.7/dist-packages, let's add it:
export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7
Now:
python -c "import sys, pprint; pprint.pprint(sys.path)"
['',
'/usr/local/lib/python2.7/site-packages/setuptools-17.1.1-py2.7.egg',
'/usr/local/lib/python2.7/site-packages/pip-7.1.0.dev0-py2.7.egg',
'/home/s-quark',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7',
'/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']
But it's still could not find module:
python -c "import gtk"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named gtk
What I have to do?