activestate pythonwin 缺失导入模块?

1 投票
2 回答
2171 浏览
提问于 2025-04-15 15:09

我正在学习DiveIntoPython.com的网站内容,但在使用导入功能时遇到了问题。我在Windows XP专业版上安装了ActiveState的Pythonwin。

在这个网站上,有一个练习需要用到'import odbchelper'和odbchelper.name

http://www.diveintopython.org/getting_to_know_python/testing_modules.html

当我在交互模式下运行时,我得到了:

>>> import odbchelper
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named odbchelper
>>> odbchelper.__name__
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
NameError: name 'odbchelper' is not defined

我在想,可能是我的路径设置不正确,或者在我运行'sys.path'时,找不到这个模块在某个文件夹里。你们有什么建议吗?

提前谢谢大家!

2 个回答

1

我搞明白了..

我找到了这个:

http://www.faqs.org/docs/diveintopython/odbchelper_divein.html

我下载了这个文件,然后把它放进一个文件夹里。在我的情况下,是放在 c:\temp\python\ 这个路径下,使用了以下命令:

>> import sys 
>> sys.path.append('c:\\temp\\python\\')
1

这个模块在Python2.6里是没有自带的(我刚在我的电脑上试过)。你有没有试着在网上搜索一下这个模块可能在哪里呢?

可以看看这个帖子

撰写回答