Python: Excluding Modules Pyinstaller

前端 未结 4 1027
有刺的猬
有刺的猬 2020-11-29 04:16

I\'ve begun using Pyinstaller over Py2Exe. However I\'ve rather quickly run into a problem. How do I exclude modules that I don\'t want, and how do I view the ones that are

4条回答
  •  萌比男神i
    2020-11-29 04:48

    Although better solutions may have been given but there is one more method: You can use the '--exclude-module' attribute with the 'pyinstaller' command but this method is quite lengthy when you have to exclude many modules.

    To make the work easier, you can write a batch script file with all the libraries worth skipping and use it again and again.

    Something like this:

    @echo off
    
    pyinstaller --onefile a.py --exclude-module matplotlib ^
                               --exclude-module scipy ^
                               --exclude-module setuptools ^
                               --exclude-module hook ^
                               --exclude-module distutils ^
                               --exclude-module site ^
                               --exclude-module hooks ^
                               --exclude-module tornado ^
                               --exclude-module PIL ^
                               --exclude-module PyQt4 ^
                               --exclude-module PyQt5 ^
                               --exclude-module pydoc ^
                               --exclude-module pythoncom ^
                               --exclude-module pytz ^
                               --exclude-module pywintypes ^
                               --exclude-module sqlite3 ^
                               --exclude-module pyz ^
                               --exclude-module pandas ^
                               --exclude-module sklearn ^
                               --exclude-module scapy ^
                               --exclude-module scrapy ^
                               --exclude-module sympy ^
                               --exclude-module kivy ^
                               --exclude-module pyramid ^
                               --exclude-module opencv ^
                               --exclude-module tensorflow ^
                               --exclude-module pipenv ^
                               --exclude-module pattern ^
                               --exclude-module mechanize ^
                               --exclude-module beautifulsoup4 ^
                               --exclude-module requests ^
                               --exclude-module wxPython ^
                               --exclude-module pygi ^
                               --exclude-module pillow ^
                               --exclude-module pygame ^
                               --exclude-module pyglet ^
                               --exclude-module flask ^
                               --exclude-module django ^
                               --exclude-module pylint ^
                               --exclude-module pytube ^
                               --exclude-module odfpy ^
                               --exclude-module mccabe ^
                               --exclude-module pilkit ^
                               --exclude-module six ^
                               --exclude-module wrapt ^
                               --exclude-module astroid ^
                               --exclude-module isort
    

    Or you can always use a new python installation, just change the path of the new python installation while installing.

提交回复
热议问题