由于cffi.api.CDefError

时间:2018-12-16 07:05:56

标签: python windows python-2.7 pyinstaller cffi

有人可以看看我的pyinstaller出了什么问题吗?

我还尝试将.py文件转换为.exe文件,但生成了相同的错误

更新。 12/15。顺便说一句,我已经在计算机上安装了python 2.7和python 3,这是问题所在吗?

但是,我尝试在C:\ Python27 \ Scripts下安装pyinstaller,以避免两个python之间的冲突。 (我不确定这是否还会导致问题,但我只是尝试列出所有我知道的问题详细信息。)

新更新。 12/16。我试图将我的目标文件(进行转换)移动到安装pyinstaller的脚本文件夹中,该文件将成功转换。但是脚本文件夹将被弄乱,因为将生成多个文件夹和文件。

我在下面添加了从cmd生成的问题:)

C:\Python27\Scripts>pip install pyinstaller
Collecting pyinstaller
Requirement already satisfied: pefile>=2017.8.1 in c:\python27\lib\site-packages (from pyinstaller) (2018.8.8)
Requirement already satisfied: pywin32-ctypes in c:\python27\lib\site-packages (from pyinstaller) (0.2.0)
Requirement already satisfied: setuptools in c:\python27\lib\site-packages (from pyinstaller) (28.8.0)
Requirement already satisfied: altgraph in c:\python27\lib\site-packages (from pyinstaller) (0.16.1)
Requirement already satisfied: macholib>=1.8 in c:\python27\lib\site-packages (from pyinstaller) (1.11)
Requirement already satisfied: dis3 in c:\python27\lib\site-packages (from pyinstaller) (0.1.2)
Requirement already satisfied: future in c:\python27\lib\site-packages (from pefile>=2017.8.1->pyinstaller) (0.17.1)
Installing collected packages: pyinstaller
Successfully installed pyinstaller-3.4

C:\Python27\Scripts>pyinstaller
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\pyinstaller.exe\__main__.py", line 5, in <module>
  File "c:\python27\lib\site-packages\PyInstaller\__init__.py", line 16, in <module>
    from . import compat
  File "c:\python27\lib\site-packages\PyInstaller\compat.py", line 212, in <module>
    from win32ctypes.pywin32 import pywintypes  # noqa: F401
  File "c:\python27\lib\site-packages\win32ctypes\pywin32\__init__.py", line 11, in <module>
    from win32ctypes.pywin32 import win32api
  File "c:\python27\lib\site-packages\win32ctypes\pywin32\win32api.py", line 12, in <module>
    from win32ctypes.core import (
  File "c:\python27\lib\site-packages\win32ctypes\core\__init__.py", line 36, in load_module
    module = importlib.import_module(self.redirect_module)
  File "c:\python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "c:\python27\lib\site-packages\win32ctypes\core\cffi\_dll.py", line 19, in <module>
    """)
  File "c:\python27\lib\site-packages\cffi\api.py", line 107, in cdef
    self._parser.parse(csource, override=override, packed=packed)
  File "c:\python27\lib\site-packages\cffi\cparser.py", line 167, in parse
    self._internal_parse(csource)
  File "c:\python27\lib\site-packages\cffi\cparser.py", line 173, in _internal_parse
ast, macros, csource = self._parse(csource)
  File "c:\python27\lib\site-packages\cffi\cparser.py", line 130, in _parse
self.convert_pycparser_error(e, csource)
  File "c:\python27\lib\site-packages\cffi\cparser.py", line 159, in convert_pycparser_error
    raise api.CDefError(msg)
cffi.api.CDefError: cannot parse "HMODULE WINAPI LoadLibraryExW(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFlags);"
:16:16: before: LoadLibraryExW

1 个答案:

答案 0 :(得分:0)

尝试使用以下命令升级cffi

pip install --upgrade cffi