导入python模块

时间:2012-10-03 04:24:25

标签: python

我尝试使用简易安装来安装模块。它似乎已经安装但我无法导入它。

# easy_install uuid
Searching for uuid
Reading http://pypi.python.org/simple/uuid/
Reading http://zesty.ca/python/
Best match: uuid 1.30
Downloading http://pypi.python.org/packages/source/u/uuid/uuid-1.30.tar.gz#md5=639b310f1fe6800e4bf8aa1dd9333117
Processing uuid-1.30.tar.gz
Running uuid-1.30/setup.py -q bdist_egg --dist-dir /tmp/easy_install-mQlxdg/uuid-1.30/egg-dist-tmp-gLpk9N
zip_safe flag not set; analyzing archive contents...
Adding uuid 1.30 to easy-install.pth file

Installed /usr/lib/python2.6/site-packages/uuid-1.30-py2.6.egg
Processing dependencies for uuid
Finished processing dependencies for uuid


# python
>>> import uuid
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named uuid


# python -V
Python 2.4.3

2 个答案:

答案 0 :(得分:3)

easy_install清楚地表明该模块已安装到/usr/lib/python2.6,但您正在运行Python 2.4。

显式运行Python 2.6(例如python2.6python26),或使用python -m easy_install uuid将模块安装到默认的Python。

答案 1 :(得分:0)

你看过你发布的内容了吗:)?

Installed /usr/lib/python2.6/site-packages/uuid-1.30-py2.6.egg

# python -V
Python 2.4.3

如果你正在使用Python 2.6(你应该这样做,因为即使现在已经很老了,2.4也很古老),uuid模块应该已经存在,所以你无论如何都不需要安装它