I already use pip with blender. On linux, you get blender to use the system python and youâre set. On windows (or if you canât get it to use system python) you can use the python binary in the 2.78 folder to install pip by running get-pip.py. There are instructions I put on on blend stackexchange a week or so ago
Why are you trying to install dependencies while the game is running? Surely itâs better to install those into your local blender, then when you export it they are distributed with the game automatically?
that does not work with OS specific libs, like pyttsx
Yes, you have to make distribution-specific releases, just like with any exported game.
pip itself isnât OS specific, so you can have that permanently installed - no need to install it every time.
Also, you will have very strange problems running pip from a blender instance. It is better to run it just using the python binary provided with blender. Why? pip is multithreaded, and for some reason, on windows, this means it opens lots of blender windows and fails to install things!
What would I suggest? A script called "install-deps.batâ (and similarly âinsall-deps.shâ on 'nix) that invokes the pip commands. Then, in your game, if it fails to import a module have it display a screen prompting the user to run that script.
From experience, itâs better to assume you cannot make any changes to a users system after installation, so bundle everything you need with the game, or get the installer to download/install any extra dependances.
User Account Control on Windows by default will prevent you installing anything into the installation directory unless youâre running the program as Admin (donât do that).
hi, im trying to use pyttsx3 in blender game but i have a lot of problems.
first in the python IDLE
error like module win32api not found
or something like win32com
then i installed pywin32 with pip install from cmd
and all works in the python IDLE.
jumping into blender i first had error when i tried to import pyttsx3
so i copied it in the blender folder version im using and its ok
but another error appeared
the same in the idle, something like win32api
i tried to copy something in the blender directory
now module pythoncom non found
can someone help me pls?
im using upbge 0.2.0 but i tried with other version too
i tried to use pyttsx and pyttsx3 both
the script im using is this just for testing:
import pyttsx3
engine = pyttsx3.init()
engine.say("I am talking now ")
engine.runAndWait()
thx all and sorry for necroposting but it is all day im looking for a solution
Part of your issue is that the python executable that blender uses and the one you develop on outside are two different executables, and they do not share any package/libraries: install something with one, the other wonât see it.
You should also understand by now that you donât want to play âcopy the folders by handâ, because when installing a package, maybe other dependencies are also required. pip knows, let pip do.
Oh and lastly, distributing such a game is not really straight forward, unless you distribute an executable version, in which case you will have to run pip inside your release before uploading it for others to use.
seems i got it, what i did , (after pip install pyttsx3 and pywin32), it was to copy site-package folder from python and pasted into my blender version site-package folder
the only thing now is that if you run the game, stop it and run it again without close blender it gives an error and doesnât work honestly dunno why, but it works fine in runtime.
mmm another problem, while pyttsx3 speaking all game angine freezes mmmm
looking at the BPR file in the first post i suppose he wanted to use subprocess for this issue, dunno.
Not sure why that would make any difference. If the function takes 3 seconds to complete, then it is going to hold up BGE from moving to the next frame for 3 seconds regardless of where in the script it is written.
global_speak_lock = Lock()
def run_me_in_a_thread():
with global_speak_lock:
if 'speaking' in object:
raise RuntimeError('I am already speaking, please wait.')
object['speaking'] = True
pyttsx.speak('whatever')
del object['speaking']
Thatâs just one way I guess.
edit: in my example, one could use the lock in a better way, oh wellâŚ
i used some different tts like win32com.client or tts.sapi with no errors in some case and the problem still remain, seems bge cant support this thing, it always freezes and restart after speech, im tring to use thread or multiprocessing but seems isnt the way but im quite noob soâŚmaybe not.
maybe opening a shell in subprocess dunno
i found this topic, it is a âlittle bitâ outdated but maybe can help
I solved that by stopping the thread when I stopped the BGE. A script attached to the ESC key will do the trick.
-edit-
Note that this is only a âproblemâ when running it inside Blender. If itâs the standalone player, then Windows/OSX will clean up orphaned threads when the game finishes.