PyInstall不适用于Kali Linux

时间:2016-01-09 18:19:44

标签: python linux pyinstaller

我正在尝试在Kali Linux上使用pyinstaller来编译python程序但是当我运行它时我遇到了一些问题:

root@kali:/usr/bin# ./pyinstaller ~/Desktop/neighbourhood.py 
14 INFO: wrote /usr/share/pyinstaller/neighbourhood/neighbourhood.spec
44 INFO: UPX is available.
520 INFO: checking Analysis
520 INFO: building Analysis because out00-Analysis.toc non existent
522 INFO: running Analysis out00-Analysis.toc
575 INFO: Analyzing /usr/share/pyinstaller/support/_pyi_bootstrap.py
1022 INFO: Analyzing /usr/share/pyinstaller/PyInstaller/loader/archive.py
1058 INFO: Analyzing /usr/share/pyinstaller/PyInstaller/loader/carchive.py
1107 INFO: Analyzing /usr/share/pyinstaller/PyInstaller/loader/iu.py
1121 INFO: Analyzing /root/Desktop/neighbourhood.py
2964 INFO: checking Tree
2964 INFO: building because out00-Tree.toc missing or bad
2964 INFO: building Tree out00-Tree.toc
2996 INFO: checking Tree
2996 INFO: building because out01-Tree.toc missing or bad
2996 INFO: building Tree out01-Tree.toc
Traceback (most recent call last):
  File "./pyinstaller.py", line 91, in <module>
    main()
  File "./pyinstaller.py", line 86, in main
    run_build(opts, spec_file)
  File "./pyinstaller.py", line 50, in run_build
    PyInstaller.build.main(spec_file, **opts.__dict__)
  File "/usr/share/pyinstaller/PyInstaller/build.py", line 1625, in main
    build(specfile, buildpath)
  File "/usr/share/pyinstaller/PyInstaller/build.py", line 1582, in build
    execfile(spec)
  File "/usr/share/pyinstaller/neighbourhood/neighbourhood.spec", line 5, in <module>
    hookspath=None)
  File "/usr/share/pyinstaller/PyInstaller/build.py", line 389, in __init__
    self.__postinit__()
  File "/usr/share/pyinstaller/PyInstaller/build.py", line 315, in __postinit__
    self.assemble()
  File "/usr/share/pyinstaller/PyInstaller/build.py", line 475, in assemble
    importTracker.analyze_script(script)
  File "/usr/share/pyinstaller/PyInstaller/depend/imptracker.py", line 205, in analyze_script
    return self.analyze_r('__main__')
  File "/usr/share/pyinstaller/PyInstaller/depend/imptracker.py", line 98, in analyze_r
    newnms = self.analyze_one(name, nm, imptyp, level)
  File "/usr/share/pyinstaller/PyInstaller/depend/imptracker.py", line 159, in analyze_one
    mod = self.doimport(nm, ctx, fqname)
  File "/usr/share/pyinstaller/PyInstaller/depend/imptracker.py", line 256, in doimport
    hooks = __import__('PyInstaller.hooks', globals(), locals(), [hookmodnm])
TypeError: Item in ``from list'' not a string

我不知道这是否有问题,但我在很多文件夹中都有pyinstaller。

root@kali:~# whereis pyinstaller
pyinstaller: /usr/bin/pyinstaller /usr/local/bin/pyinstaller /usr/share/pyinstaller

我按照youtube上的教程运行此命令:

./pyinstaller setup.py

但我在pyinstaller的文件夹中找不到setup.py。 如果运行pyinstaller没有点斜线我得到了这个:

root@kali:~# pyinstaller No handlers could be found for logger "PyInstaller.utils.misc"

任何人都知道如何修复它? 谢谢你!

1 个答案:

答案 0 :(得分:2)

如果whereis显示路径,则pyinstaller位于PATH。这意味着您不需要使用点斜杠前缀来运行pyinstaller。运行pyinstaller --version,看看它没有./前缀。

考虑输出目录将在您当前所在的目录中创建。在您的情况下/usr/bin,这是一种奇怪的选择。此外,我不明白为什么你使用root用户。

因此,如果您首先将目录更改为脚本为:

的目录,那会更好
$ cd ~/Desktop/neighbourhood.py

然后编译程序:

$ pyinstaller neighbourhood.py

关于您遇到的错误。很难说发生了什么。可能这是模块名称动态传递给python的import的问题。查看更多信息here。如果您可以在python 2和python 3之间进行选择,请使用后者来避免这种问题。

最后但并非最不重要:我强烈建议您使用official docs而不是youtube教程。