AutoGPT
AutoGPT copied to clipboard
In speak mode: ModuleNotFoundError: No module named 'gi'
Duplicates
- [X] I have searched the existing issues
Steps to reproduce 🕹
- Install via vscode + devcontainer method (on WIndows), using stable branch
- Template .env with necessary API keys and ELEVENLABS voice IDs
- Start with --speak arg
speech.mpeg file is generated and saved to disk, but the below error occurs.
Current behavior 😯
Continue (y/n): Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/workspaces/Auto-GPT/autogpt/speak.py", line 112, in speak
success = eleven_labs_speech(text, voice_index)
File "/workspaces/Auto-GPT/autogpt/speak.py", line 55, in eleven_labs_speech
playsound("speech.mpeg", True)
File "/home/vscode/.local/lib/python3.8/site-packages/playsound.py", line 91, in _playsoundNix
import gi
ModuleNotFoundError: No module named 'gi'
Beyond saying y
, all further interactions are impossible (program freezes).
Expected behavior 🤔
No response
Your prompt 📝
N/A
Same issue here.
ModuleNotFoundError: No module named 'gi'
The speech synthesis function activated with --speak argument, seems to rely on a gi
module.
I managed to fix the error by adding PyGObject
module in the requirements.txt.
This is the name of the module when installed with pip (https://pypi.org/project/PyGObject/)
It also requires three dependency packages to be installed using apt:
- libcairo2-dev
- libgirepository1.0-dev
- python3-gst-1.0
It can be done adding theses lines to the DockerFIle:
# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# Dependencies required for PyGObject pyhton module (used by ELEVENLABS speech synthesis)
&& apt -y install --no-install-recommends libcairo2-dev \
&& apt -y install --no-install-recommends libgirepository1.0-dev \
&& apt -y install --no-install-recommends python3-gst-1.0 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
It fixed the issues but now the command hangs after the AI name (without error):
vscode ➜ /workspaces/auto-gpt (feature/config-test) $ python -m autogpt --speak Speak Mode: ENABLED Welcome to Auto-GPT! Enter the name of your AI and its role below. Entering nothing will load defaults. Name your AI: For example, 'Entrepreneur-GPT' AI Name: Entrepreneur-GPT
I assume this due to a missing sound interface in the docker container, which makes sense. The next step would be to find a way to mount or link the host sound device inside the container...
I had to uninstall and reinstall the playsound
library (version 1.3.0 seems to work for me)
See this related discussion
Unfortunately the above solution didn't work for me.
Continue (y/n): Traceback (most recent call last):
File "/home/vscode/.local/lib/python3.8/site-packages/playsound.py", line 261, in <module>
playsound(argv[1])
File "/home/vscode/.local/lib/python3.8/site-packages/playsound.py", line 162, in _playsoundNix
import gi
ModuleNotFoundError: No module named 'gi'
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/workspaces/Auto-GPT/autogpt/speak.py", line 112, in speak
success = eleven_labs_speech(text, voice_index)
File "/workspaces/Auto-GPT/autogpt/speak.py", line 55, in eleven_labs_speech
playsound("speech.mpeg", True)
File "/home/vscode/.local/lib/python3.8/site-packages/playsound.py", line 254, in <lambda>
playsound = lambda sound, block = True: _playsoundAnotherPython('/usr/bin/python3', sound, block, macOS = False)
File "/home/vscode/.local/lib/python3.8/site-packages/playsound.py", line 229, in _playsoundAnotherPython
t.join()
File "/home/vscode/.local/lib/python3.8/site-packages/playsound.py", line 218, in join
raise self.exc
File "/home/vscode/.local/lib/python3.8/site-packages/playsound.py", line 211, in run
self.ret = self._target(*self._args, **self._kwargs)
File "/home/vscode/.local/lib/python3.8/site-packages/playsound.py", line 226, in <lambda>
t = PropogatingThread(target = lambda: check_call([otherPython, playsoundPath, _handlePathOSX(sound) if macOS else sound]))
File "/usr/local/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '/home/vscode/.local/lib/python3.8/site-packages/playsound.py', 'speech.mpeg']' returned non-zero exit status 1.
Unfortunately the above solution didn't work for me.
Hum.. the error seems to be the same on your side. Did you delete your container + image and re-build it ?
The error is different + more verbose from the initial post. I'll try it on another machine see if I can reproduce it.
I uninstalled version 1.2.2 of playsound and pip reinstalled it which grabbed version 1.3.0. This fixed the speak issue in my environment. Should this issue be closed?
I haven't been able to solve the Gst namespace issue yet, running VS Code on Windows with a dev container
I uninstalled version 1.2.2 of playsound and pip reinstalled it which grabbed version 1.3.0. This fixed the speak issue in my environment. Should this issue be closed?
@dmkilday I tried your solution, unfortunately it was not successful for me while running in a dev container.
I'm using autogpt outside a container at this point, which appears to work as expected.
Yes, I am not in a container either. Perhaps the issue is docker specific.
On Sat, Apr 22, 2023, 11:26 AM Yegor S @.***> wrote:
@dmkilday https://github.com/dmkilday I tried your solution, unfortunately it was not successful for me while running in a dev container.
I'm using autogpt outside a container at this point, which appears to work as expected.
— Reply to this email directly, view it on GitHub https://github.com/Significant-Gravitas/Auto-GPT/issues/1697#issuecomment-1518711984, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFDDA32KU35RFB2DUQNS753XCQICVANCNFSM6AAAAAAW7T4DW4 . You are receiving this because you were mentioned.Message ID: @.***>
I haven't been able to solve the Gst namespace issue yet, running VS Code on Windows with a dev container
I uninstalled version 1.2.2 of playsound and pip reinstalled it which grabbed version 1.3.0. This fixed the speak issue in my environment. Should this issue be closed?
I am running Python 3.11.3 in a virtual environment within WSL2, ubuntu 20.04.
I originally was having issues as well with "gi" per the original issue description but I was able to get past that after installing pyobjc in my virtual environment:
pip install pyobjc
For reference, I am using playsound 1.2.2:
pip show playsound
Name: playsound Version: 1.2.2
This was then causing the following error to be thrown when the bot attempted to use TTS to the user:
Goals: ['Increase net worth', 'Grow Twitter Account', 'Develop and manage multiple businesses autonomously'] Continue (y/n): Exception in thread Thread-1 (speak): Traceback (most recent call last): File "../.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "../.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "../Auto-GPT/autogpt/speech/say.py", line 33, in speak success = VOICE_ENGINE.say(text, voice_index) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "../Auto-GPT/autogpt/speech/base.py", line 33, in say return self._speech(text, voice_index) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "../Auto-GPT/autogpt/speech/eleven_labs.py", line 80, in _speech playsound("speech.mpeg", True) File "../Auto-GPT/autogpt1/lib/python3.11/site-packages/playsound.py", line 92, in _playsoundNix gi.require_version('Gst', '1.0') File "../Auto-GPT/autogpt1/lib/python3.11/site-packages/gi/init.py", line 126, in require_version raise ValueError('Namespace %s not available' % namespace) ValueError: Namespace Gst not available ^CYou interrupted Auto-GPT Quitting...
[above code is edited to not have full path]
I was able to get past this by performing the following global in my linux environment:
sudo apt install python3-gst-1.0
This appears to get me past the errors being thrown but now it is hanging when attempting to get to the speak portion of dialog:
Goals: ['Increase net worth', 'Grow Twitter Account', 'Develop and manage multiple businesses autonomously'] Continue (y/n): y Using memory of type: LocalCache Using Browser: chrome THOUGHTS: I think we should start by researching some potential business ideas that could help us increase net worth and grow our Twitter account. We can use the 'google' command to search for articles and resources on the topic. REASONING: Researching potential business ideas is a good starting point to help us achieve our goals. By using the 'google' command, we can quickly gather information and insights on different industries and markets. PLAN:
- Use the 'google' command to research potential business ideas
- Save important information to files for future reference CRITICISM: I need to ensure that I am not getting sidetracked by irrelevant information and that I am focusing on the most promising business ideas.
[HANGS HERE WITH NO OUTPUT]
aborting out shows:
^C Aborted! ^CException ignored in: <module 'threading' from '../.pyenv/versions/3.11.3/lib/python3.11/threading.py'> Traceback (most recent call last): File "../.pyenv/versions/3.11.3/lib/python3.11/threading.py", line 1583, in _shutdown lock.acquire() KeyboardInterrupt:
So at this point it seems, atleast for my situation with WSL2, that the audio may not be getting passed from Windows to the Linux Subsystem correctly. I am going to continue down the rabbit hole, but not sure if I will get anywhere. Would just be easier at this point to create a virtualbox with Ubuntu and build it in there.
Posted my information here for future prosperity
@DouglasC2022 thanks for posting, I came to a similar conclusion. I'm wondering if there's a solution external to Auto-GPT, but I haven't been able to hunt one down re: WSL2.
I'm going to take a stab at this issue with the goals of:
- Discovering whether this is an environment-specific issue which belongs somewhere else (Docker, WSL2, VSCode) since OP and I have similar environments
- Finding a stable fix
On macOS this requires pip3 install PyObjC
, but this does not work running from Docker because that's a separate environment. I'm on latest autogpt 0.3.0. Is there any way PyObjC could be added as a dependency when sys.platform == "darwin"
?
I'm having this issue as well when using Docker and when using a VSCode Dev Container. Tried some of the fixes from this thread with no success.
Since this issue does seem to be happening for other people, I wanted to mention a couple things I found while trying to debug
- It seems like the problem is the virtual env communicating with the sound drivers of the base OS. I have similar issues whether trying to run with
--speak
directly from WSL2, from Docker, or a VSCode Dev Container. - Based on my searches, a common solution for WSL users is to use PulseAudio https://github.com/microsoft/WSL/issues/5816
If you get PulseAudio or another solution working, or happen to know the common solution for piping audio out of a container, please report back!
This worked for me (Windows, using virtualenv): pip uninstall playsound pip install playsound==1.2.2
This worked for me (Windows, using virtualenv): pip uninstall playsound pip install playsound==1.2.2
This doesnt work for me -- can you comment on how you have your setup configured? are you using WSL2? python version?
still getting the following error: Traceback (most recent call last): File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/usr/local/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/app/autogpt/speech/say.py", line 23, in speak success = voice_engine.say(text, voice_index) File "/app/autogpt/speech/base.py", line 33, in say return self._speech(text, voice_index) File "/app/autogpt/speech/gtts.py", line 20, in _speech playsound("speech.mp3", True) File "/usr/local/lib/python3.10/site-packages/playsound.py", line 91, in _playsoundNix import gi ModuleNotFoundError: No module named 'gi'
This worked for me (Windows, using virtualenv): pip uninstall playsound pip install playsound==1.2.2
This doesnt work for me -- can you comment on how you have your setup configured? are you using WSL2? python version?
I believe that the people who are able to fix it by installing the correct playsound
version are not using WSL2. I'm not able to resolve my issue with either version of playsound
, which is why I think this issue is separate from the one mentioned here:
I had to uninstall and reinstall the
playsound
library (version 1.3.0 seems to work for me)See this related discussion
This worked for me (Windows, using virtualenv): pip uninstall playsound pip install playsound==1.2.2
This doesnt work for me -- can you comment on how you have your setup configured? are you using WSL2? python version?
Nope not using WSL2, python v3.11 (sorry for late reply!)
Hi all,
after searching a lot and trying different things here's what i've done that resolved the issue.
First i made sure i had sound working in WSL2 (ubuntu) :
look for /mnt/wslg
tried playing speech.mpeg with vlc => ok
install gstreamer : sudo apt install gst123
- installed
sudo apt install gstreamer1.0-adapter-pulseeffects gstreamer1.0-alsa
-
pip uninstall playsound
-
pip install playsound
After that : python -m autogpt --speak
worked
using python 3.11
This issue has automatically been marked as stale because it has not had any activity in the last 50 days. You can unstale it by commenting or removing the label. Otherwise, this issue will be closed in 10 days.
As far as I know this issue remains unresolved - Commenting to remove the stale tag.
This issue has automatically been marked as stale because it has not had any activity in the last 50 days. You can unstale it by commenting or removing the label. Otherwise, this issue will be closed in 10 days.
This issue was closed automatically because it has been stale for 10 days with no activity.
As far as I know this issue remains unresolved - Commenting to remove the stale tag.
I'm working on it now. Very frustrating... I'm on Ubuntu 22, Python 3.10, Jetson Orin Nano Arm64 server. Exact same error.
Exception in thread Thread-2 (_speak): Traceback (most recent call last): File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/usr/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/home/truth/AutoGPT/autogpts/autogpt/autogpt/speech/say.py", line 50, in _speak success = self._voice_engine.say(text, voice_index) File "/home/truth/AutoGPT/autogpts/autogpt/autogpt/speech/base.py", line 39, in say return self._speech(text, voice_index) File "/home/truth/AutoGPT/autogpts/autogpt/autogpt/speech/eleven_labs.py", line 87, in _speech playsound("speech.mpeg", True) File "/root/.cache/pypoetry/virtualenvs/agpt-mdKPTkzc-py3.10/lib/python3.10/site-packages/playsound.py", line 91, in _playsoundNix import gi ModuleNotFoundError: No module named 'gi'
I don't know if your problem is exactly the same as mine, but I'll share the process I went through to fix the gi module error when using playsound. The environment I was working in is a GitHub code space.
- Install Required System Packages First, install the necessary system packages to use the gi module and the Gst (GStreamer) namespace. For Ubuntu/Debian-based systems, use the following commands:
sudo apt-get update sudo apt-get install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 sudo apt-get install gstreamer1.0-tools gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gir1.2-gstreamer-1.0
- Set Up Virtual Environment With the virtual environment activated, install PyGObject:
pip install PyGObject
- Set Environment Variable Set the GI_TYPELIB_PATH environment variable so that the gi module can find the necessary type libraries:
export GI_TYPELIB_PATH="/usr/lib/girepository-1.0"
Entering this command in the terminal will apply it only to the current session. To make it permanent, add it to your ~/.bashrc file:
echo 'export GI_TYPELIB_PATH="/usr/lib/girepository-1.0"' >> ~/.bashrc source ~/.bashrc
This may resolve the issues with the gi module and allow you to use the Gst namespace in your Python scripts.