1

I am using PyInstaller to build an windows exe distributable package for a Kivy application where docutils.rst is being used. When setting console = False in the PyInstaller .spec file a virus is reported. When console = True, everything runs smoothly. When excluding docutils in the package, no virus is reported at all but then I am missing the specific docutils functionality.

Unfortunately the PyInstaller development community does not want to resolve these issues anymore and direct you to the virus software vendor.... (see: https://github.com/pyinstaller/pyinstaller/issues?q=is%3Aissue+virus+is%3Aclosed). Of course this is practically impossible when developing an application for a large diverse enterprise community.

Question 1: Does anybody know how to disable the console python console in an executable?

Otherwise I should find another direction to build a package. For example: How to compile python script to binary executable

Question 2: what do you think is the best option to move into for a package based on: python + kivy + multiprocessing + docutils.rst parser ?

For the sake of completeness, I have added my actual PyInstaller spec file:

-- mode: python --

import os
from os.path import join

from kivy import kivy_data_dir
from kivy.deps import sdl2, glew
from kivy.tools.packaging import pyinstaller_hooks as hooks

block_cipher = None
kivy_deps_all = hooks.get_deps_all()
kivy_factory_modules = hooks.get_factory_modules()

datas = [
    (join('common', '*.ini'), 'common'),
    (join('common', '*.ttf'), 'common')
]

# list of modules to exclude from analysis
excludes = ['Tkinter', '_tkinter', 'twisted', 'pygments']

# list of hiddenimports
hiddenimports = kivy_deps_all['hiddenimports'] + kivy_factory_modules
hiddenimports += ['starmeter']

# binary data
sdl2_bin_tocs = [Tree(p) for p in sdl2.dep_bins]
glew_bin_tocs = [Tree(p) for p in glew.dep_bins]
bin_tocs = sdl2_bin_tocs + glew_bin_tocs

# assets
kivy_assets_toc = Tree(kivy_data_dir, prefix=join('kivy_install', 'data'))
source_assets_toc = Tree('images', prefix='images')
assets_toc = [kivy_assets_toc, source_assets_toc]

tocs = bin_tocs + assets_toc

a = Analysis(['wflmain.py'],
             pathex=[os.getcwd()],
             binaries=None,
             datas=datas,
             hiddenimports=hiddenimports,
             hookspath=[],
             runtime_hooks=[],
             excludes=excludes,
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe1 = EXE(pyz,
           a.scripts,
           name='sgc',
           exclude_binaries=True,
           icon=join('images', 'sgc.ico'),
           debug=False,
           strip=False,
           upx=True,
           console=False)

coll = COLLECT(exe1,
               a.binaries,
               a.zipfiles,
               a.datas,
               *tocs,
               strip=False,
               upx=True,
               name='sgc')
Community
  • 1
  • 1
Bill Bridge
  • 821
  • 1
  • 9
  • 30
  • 1
    Just run `pyinstaller -w file.py` – Eular Jun 30 '16 at 14:44
  • If the problem is only packaging, set your antivirus to _ignore_ that particular file if you are sure it's not a virus (e.g. `run.exe` from official repo) and if it packages without errors, try the app. The final .exe always worked for me without any antivirus notifications. – Peter Badida Jun 30 '16 at 14:50
  • Hi KeyWeeUSr, that's what I did. But then installing the desktop app on a 3rd party system, another virus scanner reports same virus. My virus supplier F-Secure has analysed the .exe, concluded a false positive and will update their database. But what about all the other vendors.......? – Bill Bridge Jul 01 '16 at 08:16
  • @BillBridge try [signing](http://stackoverflow.com/q/252226/5994041). If this won't help then I don't have a clue. You can then only add some note to .exe file, or use different python packager. – Peter Badida Jul 01 '16 at 10:49
  • Same issue here 1 year later. You ever resolve this or find a way to disable. I cannot even suppress messages. –  Dec 11 '17 at 11:28
  • Quite sure the antivirus does not like the UPX packaging. Back then, when I was a teen playing around with trojans we would pack them with upx to make smaller files and fool Antiviruses, who would not recognize the maleware anymore because of the exe-packing. Try upx=false – leosok Nov 12 '18 at 15:46

1 Answers1

2

Question 1: Does anybody know how to disable the console python console in an executable?

pass noconsole as an argument @ CLI :

 pyinstaller --noconsole --onefile <filename>

Question 2: what do you think is the best option to move into for a package based on: python + kivy + multiprocessing + docutils.rst parser ?

Pyinstaller does a good job at compiling the dependencies, so if you are not facing any problem, the same is good to go!

Devi Prasad Khatua
  • 1,185
  • 3
  • 11
  • 23
  • Eh.. just a little detail - without [this](http://stackoverflow.com/a/36021330/5994041) answer `--onefile` won't work. Please don't provide additional args if you are not sure they work out of box (or without a way how to use them). :P – Peter Badida Jun 30 '16 at 14:54
  • 1
    Eh ...just a little other detail. In my spec file there is already the option console = False. I have added the spec file. See above. So TMHO either the -w or --noconsole just won't be a valid option..... – Bill Bridge Jul 01 '16 at 08:10
  • `--onefile` didn't work for me. But this did: `'pyinstaller --noconsole '` – Chris Nielsen Aug 02 '17 at 20:41
  • The specfile overrides most of these options, so they often don't work... – noname May 02 '19 at 14:46