This is the imported lib in my code
from tkinter import *
from BacaRupa import main_detect, check_temp
from multiprocessing import Value
from ctypes import Structure, c_double
from PIL import Image, ImageTk
from Logo import *
import tkinter.font as tkFont
import os
import sys
import serial.tools.list_ports
import multiprocessing
I'm using this code to run multiprocessing.
try:
# Python 3.4+
if sys.platform.startswith('win'):
import multiprocessing.popen_spawn_win32 as forking
else:
import multiprocessing.popen_fork as forking
except ImportError:
import multiprocessing.forking as forking
if sys.platform.startswith('win'):
class _Popen(forking.Popen):
def __init__(self, *args, **kw):
if hasattr(sys, 'frozen'):
# We have to set original _MEIPASS2 value from sys._MEIPASS
# to get --onefile mode working.
os.putenv('_MEIPASS2', sys._MEIPASS)
try:
super(_Popen, self).__init__(*args, **kw)
finally:
if hasattr(sys, 'frozen'):
# On some platforms (e.g. AIX) 'os.unsetenv()' is not
# available. In those cases we cannot delete the variable
# but only set it to the empty string. The bootloader
# can handle this case.
if hasattr(os, 'unsetenv'):
os.unsetenv('_MEIPASS2')
else:
os.putenv('_MEIPASS2', '')
# Second override 'Popen' class with our modified version.
forking.Popen = _Popen
class Process(multiprocessing.Process):
_Popen = _Popen
This function get called by if name == 'main':
def PanggilBacaRupa():
import time
y = Value(c_double, 0)
is_stop = Value('i',0)
multiprocessing.freeze_support()
p = Process(target=check_temp, args=(y,is_stop))
p.start()
if entrySuhu.get() == "":
main_detect(y, is_stop, 0)
else:
main_detect(y, is_stop, entrySuhu.get())
When runned using python this program run successfully, but when compiled to .exe this program can't do multiprocessing. What should i do? i compiled with pyinstaller GUI.spec --windowed --onefile.