1

过去几个月我一直在使用 Python,在 3.3 版本中编写了一些应用程序我现在需要编写一个仅在 v2 中引用模块的应用程序,所以我开始使用 Python 2.7.5 我写了一个类似的应用程序在 v3 中,所以我想我会从修改我在 3.3 到 2.7.5 中使用的一些代码开始

但是,我还处于起步阶段,并且已经被难住了。我为 2.7 下载了 python 2.7 和 pywin32。但是,我收到涉及 win32com.client 所需的 win32api 模块的导入错误。

这是我在 3.3 中使用的代码,它有效

from win32com.client import Dispatch
from adodbapi import *
from time import sleep
import os
import xml.etree.ElementTree as ET
import urllib
import string
import csv

from urllib.request import urlopen
from xml.sax.saxutils import escape
from urllib.parse import urlencode
from urllib.parse import quote

这是2.7的代码,它不起作用

from win32com.client import Dispatch
import adodbapi 
from time import sleep
import os
import xml.etree.ElementTree as ET
import urllib, urllib2
import string
import csv

from urllib2 import urlopen 
from xml.sax.saxutils import escape
from urllib import urlencode
from urllib import quote

我得到的具体错误是

Traceback (most recent call last):
  File "C:\Users\...", line 1, in <module>
    from win32com.client import Dispatch
  File "C:\Python27\lib\site-packages\win32com\__init__.py", line 5, in <module>
    import win32api, sys, os
ImportError: DLL load failed: The specified module could not be found.

当我跑步时

help ('modules')

在 2.7.5 中,我看到 win32api 确实存在并且由 PYTHONPATH 找到。我可以毫无问题地导入系统和操作系统。问题肯定在于win32api。这似乎很基本。我错过了什么??

4

0 回答 0