Package python's py file into exe,

Source: Internet
Author: User

Package python's py file into exe,
1. Install Pyinstaller first-use pip to install the module (I installed a python compiling environment named Anaconda on my computer. If the computer installed python IDE, directly go to the python installation path, for example, "D: \ python27 \ Scripts \ pip.exe") My Anaconda2 is installed on the G disk, so use the following path -- execute the statement: pip.exe install PyInstallercmd To Go To The python installation directory (cd "G: \ Anaconda2 \ Anaconda2 \ Scripts"). Another advantage of pip installation is that, pip will automatically install the dependent modules required by this third-party package (for example, we have downloaded the dependency of pypiwin32 here ). 2. Start cmd to package the py file into the exe file. The pyinstaller folder is located at: G: \ Anaconda2 \ Anaconda2 \ Lib \ site-packages. (If Anaconda2 is not installed, only python is installed, then, pyinstaller should be located in [your installation directory \ python27 \ Lib \ site-packages]) (1) in the site-packages folder, create a new folder named myexe to store the py file to be converted into exe. (2) run the command prompt to enter the myexe folder. (3) run the command prompt to enter the pyinstaller-F file name. py; pay attention to space and Case sensitivity. (For example, pyinstaller-F mytest. py] (4) several files are generated in the folder, where the exe file is in the dist folder. Iii. Problems and Solutions: 1. The Program Reports ImportError: The 'packaging' package is required when pyinstaller is used for packaging; normally this is bundled with this package so if you get this warning, consult the packager of your distribution. solution: the version of the setuptools package is too high, and the setuptools version in the environment is 20. x. x. Uninstall and install the lower version of setuptools (19.2) as follows:

pip uninstall setuptoolspip install setuptools==19.2
2, but in the run pip uninstall setuptools error, can not find the "easy-install.pth" file, so the way to manually uninstall: manually delete files and folders from third-party modules or packages in Python, and then delete the corresponding lines in the easy-install.pth file. (I found the problem is that I installed Anaconda2, rather than simply python, so the directory is different from the default directory, the uninstall method can not find the easy-install.pth, because in Anaconda2, the installation information of steuptools is named setuptools. in the pth file, set the steuptools package and the setuptools. you can delete all pth files.) refer to the blog post: Installing install setuptools = 19.2 to solve the problem. 4. You have encountered the problem that a package cannot be found during packaging, someone said on the Internet that the missing package is imported in The py file, and then found in the site-package under the python installation directory. The corresponding package is copied to the same directory where the pyinstaller file is located, but I later found that if you install the pyinstaller in pip mode, this problem does not occur. Reference: http://jingyan.baidu.com/article/a378c960b47034b3282830bb.htmlhttp://blog.csdn.net/churximi/article/details/50321853http://blog.csdn.net/kongxx/article/details/51037331

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.