简体   繁体   English

Python-编译时sys.path [0]不起作用

[英]Python - sys.path[0] not working when compiled

I use pyinstaller to compile my python file but instead of sys.argv[0] printing out my current directory it prints out a completely random directory in %appdata% why? 我使用pyinstaller编译我的python文件,但是不是sys.argv [0]打印出我的当前目录,而是在%appdata%中打印出了一个完全随机的目录,为什么?

Here is my code: 这是我的代码:

import sys

print(sys.argv[0])

Command ran: 命令运行:

pyinstaller.exe s.py --onefile

The output is: 输出为:

C:\Users\Zeref\AppData\Local\Temp\_MEI5002\base_library.zip

Instead of: 代替:

C:\Users\Zeref\Desktop\compile\compiled

Try this instead: 尝试以下方法:

print(sys._MEIPASS)
print(sys.executable)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM