我通过以下方式在我的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 <DIR> .
04/05/2013 06:06 PM <DIR> ..
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 <DIR> setuptools
04/05/2013 05:33 PM <DIR> setuptools-0.6c11-py2.7.egg-info
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 <DIR> xlrd
04/05/2013 05:27 PM 975 xlrd-0.7.3-py2.7.egg-info
但是当我去python翻译时,我得到了:
>>>import pytz
Traceback (most recent call last):
File "<console>", line 1, in <module>
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)
我从./pytz-2013b-py2.7.egg
文件中删除了easy_install.pth
并尝试了easy_install pytz
。这次它安装了,我可以import pytz
没有先前报告的错误(为什么这会解决问题?)。
但是,我的ecplise / pydev似乎仍然没有承认import pytz
声明。它无法解决它。它也无法解析import sqlalchemy
但dos python解释器可以同时导入它们。如果你去C:\Python27\python.exe
,eclipse / pydev中的python解释器设置为Windows > Preferences > Interpreter - Python
。
有趣的是我必须在项目中检查我的解释器配置。我只是假设项目在给定全局设置的情况下会知道。但我猜不是。
现在一切正常。非常感谢大家。
答案 0 :(得分:1)
一些想法:
import sys; sys.executable
检查正在运行的内容。