Pyinstaller networkx模块问题

时间:2016-08-08 12:16:51

标签: python-2.7 networkx pyinstaller

我有一个来自networkx示例的python文件:

from networkx import Graph

G=Graph()
G.add_node("spam")
G.add_edge(1,2)
print(list(G.nodes()))
print(list(G.edges()))

现在我想使用pyinstaller来构建bin文件

pyinstaller --debug --onedir nx.py

构建并运行nx.exe后,我在cmd中收到此错误:

PyInstaller Bootloader 3.x
LOADER: executable is C:\Users\XRP836\Desktop\MeshSim\ex\dist\nx\nx.exe
LOADER: homepath is C:\Users\XRP836\Desktop\MeshSim\ex\dist\nx
LOADER: _MEIPASS2 is NULL
LOADER: archivename is C:\Users\XRP836\Desktop\MeshSim\ex\dist\nx\nx.exe
LOADER: No need to extract files to run; setting extractionpath to homepath
LOADER: SetDllDirectory(C:\Users\XRP836\Desktop\MeshSim\ex\dist\nx)
LOADER: Already in the child - running user's code.
LOADER: Python library: C:\Users\XRP836\Desktop\MeshSim\ex\dist\nx\python27.dll
LOADER: Loaded functions from Python library.
LOADER: Manipulating environment (sys.path, sys.prefix)
LOADER: sys.prefix is C:\Users\XRP836\Desktop\MeshSim\ex\dist\nx
LOADER: Setting runtime options
LOADER: Initializing python
LOADER: Overriding Python's sys.path
LOADER: Post-init sys.path is C:\Users\XRP836\Desktop\MeshSim\ex\dist\nx
LOADER: Setting sys.argv
LOADER: setting sys._MEIPASS
LOADER: importing modules from CArchive
LOADER: extracted struct
LOADER: callfunction returned...
LOADER: extracted pyimod01_os_path
LOADER: callfunction returned...
LOADER: extracted pyimod02_archive
LOADER: callfunction returned...
LOADER: extracted pyimod03_importers
LOADER: callfunction returned...
LOADER: Installing PYZ archive with Python modules.
LOADER: PYZ archive: out00-PYZ.pyz
LOADER: Running pyiboot01_bootstrap.py
LOADER: Running pyi_rth_pkgres.py
Traceback (most recent call last):
  File "site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py", line 11, in <module>
  File "c:\users\xrp836\appdata\local\temp\pip-build-hppbcz\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line
389, in load_module
  File "site-packages\pkg_resources\__init__.py", line 2958, in <module>
  File "site-packages\pkg_resources\__init__.py", line 2944, in _call_aside
  File "site-packages\pkg_resources\__init__.py", line 2986, in _initialize_master_working_set
UnboundLocalError: local variable 'dist' referenced before assignment
Failed to execute script pyi_rth_pkgres
LOADER: OK.
LOADER: Cleaning up Python interpreter.

据我所知,我需要为pyinstaller(hook-networkx.py)创建钩子文件,但我真的不知道如何正确地做到这一点。或者我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:0)

通过将pyinstaller降级到3.1版本来解决问题。