Closed. This question is off-topic。它当前不接受答案。
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
2年前关闭。
我正在尝试在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"
谁知道怎么修它?
谢谢!
python大神给出的解决方案
如果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教程。
如果修改脚本和脚本名称以退出progrom,则有任何技巧[关闭] - pythonClosed. This question needs details or clarity。它当前不接受答案。 …
有什么方法可以远程发出telnet命令并重复两次telnet会话? [关闭] - pythonIt's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current fo…
用大写字母拆分字符串,但忽略AAA Python Regex - python我的正则表达式:vendor = "MyNameIsJoe. I'mWorkerInAAAinc." ven = re.split(r'(?<=[a-z])[A-Z]|[A-Z](?=[a-z])', vendor) 以大写字母分割字符串,例如:'我的名字是乔。 I'mWorkerInAAAinc”变成…
Python sqlite3数据库已锁定 - python我在Windows上使用Python 3和sqlite3。我正在开发一个使用数据库存储联系人的小型应用程序。我注意到,如果应用程序被强制关闭(通过错误或通过任务管理器结束),则会收到sqlite3错误(sqlite3.OperationalError:数据库已锁定)。我想这是因为在应用程序关闭之前,我没有正确关闭数据库连接。我已经试过了: connectio…
将sys.arvg与列表进行比较[关闭] - pythonClosed. This question is off-topic。它当前不接受答案。 …