Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
417 views
in Technique[技术] by (71.8m points)

python 3.x - How to include files while compiling?

I am using pyinstaller to compile a python script to an exe, but before I do that I want to obfuscate it using pyarmor, I fired up pyarmor web ui using pyarmor-webui and created a build that gives out a file named the same one as the file I want to compile but obfuscated and a folder containing two files __init__.py and _pytransform.dll now when I try to compile the obfuscated code into an exe using pyinstaller --onefile myfile.py I get an executable that when I run from a batchfile to look at the output it throws the following error Could not find "C:Users000AppDataLocalTemp\_MEI72482pytransformplatformswindowsx86_64\_pytransform.dll"

myfile.py

import os 
import random 

for i in range (10):
    print (random.randrange(1,100))

Batch file

try_01.exe
pause

How and what do I need to add to pyinstaller command so that it includes the .dll file in the compilation process

question from:https://stackoverflow.com/questions/65876402/how-to-include-files-while-compiling

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The pyinstaller docs say the following:

--add-binary <SRC;DEST or SRC:DEST>

Additional binary files to be added to the executable. See the --add-data option for more details. This option can be used multiple times.

I haven't used pyarmor+pyinstaller before but it should be as simple as:

pyinstaller --onefile myfile.py --add-binary _pytransform.dll

Or, since I looked more into pyarmor's output, it may be:

pyinstaller --onefile myfile.py _pytransform.dll

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...