In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Pythonexe practical application of the eight steps, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Practical steps
Note: suppose python is installed in the c:\ python25 directory, and the executable files of * are placed in the d:\ dist directory
1. First go to the c:\ python25\ Lib directory and copy all the files, such as to the d:\ pythonlib directory
two。 Open a cmd window, go to the d:\ pythonlib directory, and run python-OO compileall.py-f. Compile all the .py files in lib into .pyo files.
3. Delete all .py and .pyc files in the d:\ pythonlib directory, because we only need .pyo files to get these libraries running.
4. Delete all unused files in the directory, such as curses,test,idlelib,msilib, etc., to reduce the size of the generated files.
5. Package these libraries into a zip file, such as stdlib.zip, and put them in the d:\ dist directory
6. Copy the .pyd and .dll files in the c:\ python25\ dlls directory to the d:\ dist\ dlls directory, of course, delete some files that are impossible to use, such as _ msi.pyd,_ssl.pyd, etc., you can reduce the size of the files.
7. Pack the program you wrote into a mysrc.zip package as described in steps 2 to 5, and put it in the d:\ dist directory. Note: the entry of the self-written program should be the main.pyo file.
8. Use the following C program to compile an executable file, such as runpy.exe, and put it in d:\ dist.
# include # include int main () {
Get the directory where the current executable file is located
Char szPath [10240]; char szCmd [10240]; GetModuleFileName (NULL, szPath, sizeof (szPath)); char* p = strrchr (szPath,'\\'); if (p = = NULL) {printf ("Get module file name error!\ n"); return-1;} * p = 0
Set the runtime PATH
Sprintf (szCmd, "PATH=%s\\ dlls;%%PATH%%", szPath); _ putenv (szCmd)
Set sys.path to ['.', 'own source code zip file', 'standard library zip file', 'dll directory']
Then call the main module
Sprintf (szCmd, "import sys\ n"sys.path= ['.', ringing% s\\ mysrc.zip', ringing% s\\ stdlib.zip', ringing% s\\ dlls']\ n" import main\ n ", szPath, szPath, szPath); Py_OptimizeFlag = 2; Py_NoSiteFlag = 1; Py_Initialize (); PyRun_SimpleString (szCmd); return 0; is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.