我正在尝试编译我的Windows项目。我在Windows 2008 32位。
它编译时没有任何问题,但是当我尝试打开EXE时,它说它无法导入cefpython_27。问题来自于site-packages中cefpython中的这个文件:( init .py)
import sys
if 0x02070000 <= sys.hexversion < 0x03000000:
from . import cefpython_py27 as cefpython
elif 0x03000000 <= sys.hexversion < 0x04000000:
from . import cefpython_py32 as cefpython
else:
raise Exception("Unsupported python version: " + sys.version)
__version__ = "27.3"
__author__ = "The CEF Python authors"
我怀疑问题在于这一行:
from . import cefpython_py27 as cefpython
因为该路径与EXE文件无关。
我应该如何导入?
这是我的setup.py文件:
from distutils.core import setup
import py2exe, os
def get_cefpython_path():
from cefpython3 import cefpython
path = os.path.dirname(cefpython.__file__)
return "%s%s" % (path, os.sep)
def get_data_files():
cefp = get_cefpython_path()
data_files = [('', ['%s/icudt.dll' % cefp,
'%s/d3dcompiler_43.dll' % cefp,
'%s/devtools_resources.pak' % cefp,
'%s/ffmpegsumo.dll' % cefp,
'%s/libEGL.dll' % cefp,
'%s/libGLESv2.dll' % cefp,
'%s/Microsoft.VC90.CRT.manifest' % cefp,
'%s/msvcm90.dll' % cefp,
'%s/msvcp90.dll' % cefp,
'%s/msvcr90.dll' % cefp]),
('locales', ['%s/locales/en-US.pak' % cefp]),
]
print data_files
return data_files
setup(
console=['videoinbox.py'],
data_files = get_data_files()
)
这是试图打开EXE的错误:
Traceback (most recent call last):
File "videoinbox.py", line 41, in <module>
from cefpython3 import cefpython
File "cefpython3\__init__.pyc", line 4, in <module>
ImportError: cannot import name cefpython_py27
更新
所以我查看了library.zip文件并查看了cefpython3目录。只有 init .py文件。这一定是它抱怨的原因。然后我尝试构建该文件并且它抱怨所以我在同一个目录中添加了文件[cefpython_py27.pyd,icudt.dll],然后它在手动调用时运行。
现在我不知道如何从py2exe的构建中包含这些内容?但即使我将其添加到zip文件中,它仍然没有找到它。 Altough解压zip并执行python init .py它可以工作!