我通过以下方式在windows7计算机上安装了pytz软件包:C:\Users\name\Downloads\pytz>easy_install --upgrade pytz
Searching for pytz
Reading http://pypi.python.org/simple/pytz/
Reading http://pytz.sourceforge.net
Reading http://sourceforge.net/project/showfiles.php?group_id=79122
Reading http://www.stuartbishop.net/Software/pytz
Reading http://sourceforge.net/projects/pytz/
Best match: pytz 2013b
Downloading http://pypi.python.org/packages/2.7/p/pytz/pytz-2013b-py2.7.egg#md5=7cfcc57ddb87125a042b70c03580d6cf
Processing pytz-2013b-py2.7.egg
Moving pytz-2013b-py2.7.egg to c:\python27\lib\site-packages
Adding pytz 2013b to easy-install.pth file
Installed c:\python27\lib\site-packages\pytz-2013b-py2.7.egg
Processing dependencies for pytz
Finished processing dependencies for pytz
C:\Python27\Lib\site-packages>dir
Volume in drive C has no label.
Volume Serial Number is 485C-3867
我检查了.egg文件是否在python27\lib\site packages目录中:Directory of C:\Python27\Lib\site-packages
04/05/2013 06:06 PM
04/05/2013 06:06 PM
04/05/2013 06:06 PM 237 easy-install.pth
09/20/2006 10:05 AM 126 easy_install.py
04/05/2013 05:33 PM 312 easy_install.pyc
04/05/2013 05:33 PM 312 easy_install.pyo
10/19/2009 06:35 AM 85,435 pkg_resources.py
04/05/2013 05:33 PM 90,779 pkg_resources.pyc
04/05/2013 05:33 PM 90,779 pkg_resources.pyo
04/05/2013 06:06 PM 521,259 pytz-2013b-py2.7.egg
03/08/2011 10:39 AM 121 README.txt
04/05/2013 05:33 PM
04/05/2013 05:33 PM
09/20/2006 10:05 AM 2,362 site.py
04/05/2013 05:33 PM 1,719 site.pyc
04/05/2013 05:33 PM 1,719 site.pyo
04/05/2013 05:36 PM 1,784,796 sqlalchemy-0.8.0-py2.7.egg
04/05/2013 05:27 PM
04/05/2013 05:27 PM 975 xlrd-0.7.3-py2.7.egg-info
但是当我转到python解释器时,我得到:>>>import pytz
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named pytz
当我在PyDev中打开一个.py文件时,它声称import pytz语句未解析。找不到包裹。
我很感激你的帮助。谢谢您。
*编辑*
easy_install.pth的内容:import sys; sys.__plen = len(sys.path)
./sqlalchemy-0.8.0-py2.7.egg
./pytz-2013b-py2.7.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
我从easy_install.pth文件中删除了./pytz-2013b-py2.7.egg,并尝试了easy_install pytz。这次安装了它,我可以import pytz而不出现前面报告的错误(为什么要修复这个问题?)。
然而,我的ecplise/pydev似乎仍然不承认import pytz语句。它不能解决它。它也不能解析import sqlalchemy,但是dos python解释器可以同时导入这两个。如果转到Windows > Preferences > Interpreter - Python,eclipse/pydev中的python解释器设置为C:\Python27\python.exe。
有趣的是,我不得不在项目中检查我的解释器配置。我只是假设,考虑到全局设置,项目会知道。但我想不是。
现在一切正常了。非常感谢大家。