Python Forum
Cant install gtts module Python 3.4 [SOLVED]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant install gtts module Python 3.4 [SOLVED]
#1
I cant install the google text to speech module (gtts) on Python 3.4.2
OS is Linux Mint 17.3 and using pip3.

Gtts appears to download and install...

Quote:sudo pip3 install gtts
Downloading/unpacking gtts
Downloading gTTS-2.0.3.tar.gz
Running setup.py (path:/tmp/pip_build_root/gtts/setup.py) egg_info for package gtts

Installing collected packages: gtts
Running setup.py install for gtts

Successfully installed gtts
Cleaning up...

|However list of pip3 packages shows:
pip3 list
apt-clone (0.2.1)
gTTS-token (1.1.3)
pexpect (3.1)
Pillow (2.3.0)
pip (1.5.4)
setuptools (3.3)
six (1.5.2)
UNKNOWN (2.0.3)
urllib3 (1.7.1)


The current verion of gtts is 2.0.3
https://pypi.org/project/gTTS/#files

and the UNKNOWN item also has 2.0.3

If I start a python shell and try and import gtts , the module is not found:

 python3
Python 3.4.3 (default, Nov 12 2018, 22:25:49) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtts
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'gtts'
>>> from gtts import gTTS
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'gtts'
>>> 
Thanks in advance for any help.
I have it working fine on python3.5 on a different computer just cant
get it working on this version.
Reply
#2
first you shouldn't need to use sudo.
You may have multiple versions of python installed, and each version has it's own pip which will only install to that version.
At the start of your post you say you want to install on Python 3.4.2, yet in your listing you show: Python 3.4.3 (default, Nov 12 2018, 22:25:49)
You can see which versions are being used by:
python -V
which python
pip -V
which pip
Reply
#3
Thanks for ypur quick reply. On Linux Mint pip3 has to be used with sudo as its a system wide install
and python (refers to python2, while python3 is for p[ython3 branch).

I've posted the outputs of the commands though and yes its is python3.4.3 sorry for misleading info:

which python3
/usr/bin/python3

which pip3
/usr/bin/pip3

pip3 -V
pip 1.5.4 from /usr/lib/python3/dist-packages (python 3.4)

python3 -v (output long so in quote)
import _frozen_importlib # frozen
import imp # builtin
import sys # builtin
# installing zipimport hook
# installed zipimport hook
# /usr/lib/python3.4/encodings/__pycache__/__init__.cpython-34.pyc matches /usr/lib/python3.4/encodings/__init__.py
# code object from '/usr/lib/python3.4/encodings/__pycache__/__init__.cpython-34.pyc'
# /usr/lib/python3.4/__pycache__/codecs.cpython-34.pyc matches /usr/lib/python3.4/codecs.py
# code object from '/usr/lib/python3.4/__pycache__/codecs.cpython-34.pyc'
import 'codecs' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44c0ecf8>
# /usr/lib/python3.4/encodings/__pycache__/aliases.cpython-34.pyc matches /usr/lib/python3.4/encodings/aliases.py
# code object from '/usr/lib/python3.4/encodings/__pycache__/aliases.cpython-34.pyc'
import 'encodings.aliases' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44c24828>
import 'encodings' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44c0e8d0>
# /usr/lib/python3.4/encodings/__pycache__/utf_8.cpython-34.pyc matches /usr/lib/python3.4/encodings/utf_8.py
# code object from '/usr/lib/python3.4/encodings/__pycache__/utf_8.cpython-34.pyc'
import 'encodings.utf_8' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44bb1518>
# /usr/lib/python3.4/encodings/__pycache__/latin_1.cpython-34.pyc matches /usr/lib/python3.4/encodings/latin_1.py
# code object from '/usr/lib/python3.4/encodings/__pycache__/latin_1.cpython-34.pyc'
import 'encodings.latin_1' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44bb4080>
# /usr/lib/python3.4/__pycache__/io.cpython-34.pyc matches /usr/lib/python3.4/io.py
# code object from '/usr/lib/python3.4/__pycache__/io.cpython-34.pyc'
# /usr/lib/python3.4/__pycache__/abc.cpython-34.pyc matches /usr/lib/python3.4/abc.py
# code object from '/usr/lib/python3.4/__pycache__/abc.cpython-34.pyc'
# /usr/lib/python3.4/__pycache__/_weakrefset.cpython-34.pyc matches /usr/lib/python3.4/_weakrefset.py
# code object from '/usr/lib/python3.4/__pycache__/_weakrefset.cpython-34.pyc'
import '_weakrefset' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44bb4d68>
import 'abc' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44bb4550>
import 'io' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44bb42b0>
# /usr/lib/python3.4/__pycache__/site.cpython-34.pyc matches /usr/lib/python3.4/site.py
# code object from '/usr/lib/python3.4/__pycache__/site.cpython-34.pyc'
# /usr/lib/python3.4/__pycache__/os.cpython-34.pyc matches /usr/lib/python3.4/os.py
# code object from '/usr/lib/python3.4/__pycache__/os.cpython-34.pyc'
# /usr/lib/python3.4/__pycache__/stat.cpython-34.pyc matches /usr/lib/python3.4/stat.py
# code object from '/usr/lib/python3.4/__pycache__/stat.cpython-34.pyc'
import 'stat' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44bdd2b0>
# /usr/lib/python3.4/__pycache__/posixpath.cpython-34.pyc matches /usr/lib/python3.4/posixpath.py
# code object from '/usr/lib/python3.4/__pycache__/posixpath.cpython-34.pyc'
# /usr/lib/python3.4/__pycache__/genericpath.cpython-34.pyc matches /usr/lib/python3.4/genericpath.py
# code object from '/usr/lib/python3.4/__pycache__/genericpath.cpython-34.pyc'
import 'genericpath' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44be0b70>
import 'posixpath' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44bdd518>
# /usr/lib/python3.4/__pycache__/_collections_abc.cpython-34.pyc matches /usr/lib/python3.4/_collections_abc.py
# code object from '/usr/lib/python3.4/__pycache__/_collections_abc.cpython-34.pyc'
import '_collections_abc' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44be0a90>
import 'os' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44bccb00>
# /usr/lib/python3.4/__pycache__/_sitebuiltins.cpython-34.pyc matches /usr/lib/python3.4/_sitebuiltins.py
# code object from '/usr/lib/python3.4/__pycache__/_sitebuiltins.cpython-34.pyc'
import '_sitebuiltins' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44bccac8>
# /usr/lib/python3.4/__pycache__/sysconfig.cpython-34.pyc matches /usr/lib/python3.4/sysconfig.py
# code object from '/usr/lib/python3.4/__pycache__/sysconfig.cpython-34.pyc'
import 'sysconfig' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44b96630>
# /usr/lib/python3.4/__pycache__/_sysconfigdata.cpython-34.pyc matches /usr/lib/python3.4/_sysconfigdata.py
# code object from '/usr/lib/python3.4/__pycache__/_sysconfigdata.cpython-34.pyc'
# /usr/lib/python3.4/plat-x86_64-linux-gnu/__pycache__/_sysconfigdata_m.cpython-34.pyc matches /usr/lib/python3.4/plat-x86_64-linux-gnu/_sysconfigdata_m.py
# code object from '/usr/lib/python3.4/plat-x86_64-linux-gnu/__pycache__/_sysconfigdata_m.cpython-34.pyc'
import '_sysconfigdata_m' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44b981d0>
import '_sysconfigdata' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44b9cf60>
# /usr/lib/python3.4/__pycache__/_bootlocale.cpython-34.pyc matches /usr/lib/python3.4/_bootlocale.py
# code object from '/usr/lib/python3.4/__pycache__/_bootlocale.cpython-34.pyc'
import '_bootlocale' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44afc240>
# /usr/lib/python3.4/__pycache__/sitecustomize.cpython-34.pyc matches /usr/lib/python3.4/sitecustomize.py
# code object from '/usr/lib/python3.4/__pycache__/sitecustomize.cpython-34.pyc'
import 'sitecustomize' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44b01080>
import 'site' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44bc3630>
Python 3.4.3 (default, Nov 12 2018, 22:25:49) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
# extension module loaded from '/usr/lib/python3.4/lib-dynload/readline.cpython-34m-x86_64-linux-gnu.so'
# /usr/lib/python3.4/__pycache__/rlcompleter.cpython-34.pyc matches /usr/lib/python3.4/rlcompleter.py
# code object from '/usr/lib/python3.4/__pycache__/rlcompleter.cpython-34.pyc'
import 'rlcompleter' # <_frozen_importlib.SourceFileLoader object at 0x7f5d44b09f28>
I can post commands for pip and python but these are for python2 branch and I'm working with
python3. Thanks again for help.
Reply
#4
Is there a gtts in /usr/lib/python3.4/site-packages ?
Reply
#5
Hi I dont have site packages in that directory:

/usr/lib/python3.4 > ls s*
sched.py sitecustomize.py socket.py ssl.py struct.py sysconfig.py
selectors.py site.py socketserver.py statistics.py subprocess.py
shelve.py smtpd.py sre_compile.py stat.py sunau.py
shlex.py smtplib.py sre_constants.py stringprep.py symbol.py
shutil.py sndhdr.py sre_parse.py string.py symtable.py


However I had a look in /usr/local/lib/python3.4

/usr/local/lib/python3.4 > ls
dist-packages/ site-packages/

This directory has two further directories. The only item in site-packages is an entry for
lirc however the contents of dist-packages:


/usr/local/lib/python3.4/dist-packages > ls
gtts_token httplib2-0.11.3.egg-info pyttsx
gTTS_token-1.1.3.egg-info pysftpserver pyttsx-1.1.egg-info
httplib2 pysftpserver-1.4.0.egg-info UNKNOWN-2.0.3.egg-info

There is an entry for gtts_token but not gtts however UNKNOWN-2.03.egg-info matches the
same version of gtts 2.0.3.

I'm not sure if this information is relevant so await further instructions.
Reply
#6
I think it's strange that /usr/local/lib/python3.4/dist-packages is not already in sys.path. Check
Output:
/usr/bin/python3.4 -c "import sys; print(sys.path)"
If it is not in this list, you could edit /usr/lib/python3.4/sitecustomize.py (as administrator) and add these lines
import site
site.addsitedir('/usr/local/lib/python3.4/dist-packages')
site.addsitedir('/usr/local/lib/python3.4/site-packages')
If you don't want to edit this file, you can run in a terminal
Output:
/usr/bin/python3.4 -c "import site; print(site.getusersitepackages())"
this gives you the name of a directory under your home folder. In this directory, you can create a file named usercustomize.py containing the above three lines.
Reply
#7
Ran first command and posting output of sys.path:

/usr/bin/python3.4 -c "import sys; print(sys.path)"
Quote:Command output
['', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python3/dist-packages']
Reply
#8
It is really strange that you don't see a gtts directory. You can find it with locate for example
Output:
sudo apt install mlocate sudo updatedb # may take some time locate gtts
Reply
#9
Finally got it solved. I hunted for the UNKNOWN package and read the .egg
info. All it contained in all fields was UNKNOWN (in caps).
Then I read about python packaging on:

https://packaging.python.org/discussions/wheel-vs-egg/

As I'm still new to Python (less than a year) it seems that the
old packaging egg format used setuptools where newer can use wheel.
My setuptools was version 3.3

I used
Quote:sudo pip3 install setuptools --upgrade
sudo pip3 uninstall UNKNOWN
sudo pip3 install gTTS

After a few tense moments the output was:
Downloading/unpacking gTTS
  Downloading gTTS-2.0.3.tar.gz
  Running setup.py (path:/tmp/pip_build_root/gTTS/setup.py) egg_info for package gTTS
    /tmp/pip_build_root/gTTS/setup.py:12: PkgResourcesDeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python3/dist-packages (from gTTS)
Downloading/unpacking bs4 (from gTTS)
  Downloading bs4-0.0.1.tar.gz
  Running setup.py (path:/tmp/pip_build_root/bs4/setup.py) egg_info for package bs4
    /tmp/pip_build_root/bs4/setup.py:12: PkgResourcesDeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
      long_description="""Use `beautifulsoup4 <https://pypi.python.org/pypi/beautifulsoup4>`_ instead.""",    # noqa
Downloading/unpacking click (from gTTS)
  Downloading Click-7.0-py2.py3-none-any.whl (81kB): 81kB downloaded
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python3/dist-packages (from gTTS)
Downloading/unpacking gtts_token (from gTTS)
  Downloading gTTS-token-1.1.3.tar.gz
  Running setup.py (path:/tmp/pip_build_root/gtts-token/setup.py) egg_info for package gtts-token
    /tmp/pip_build_root/gtts-token/setup.py:12: PkgResourcesDeprecationWarning: Parameters to load are deprecated.  Call .resolve and .require separately.
      author_email='[email protected]',
    warning: no files found matching 'CHANGES.txt'
Requirement already satisfied (use --upgrade to upgrade): beautifulsoup4 in /usr/lib/python3/dist-packages (from bs4->gTTS)
Installing collected packages: gTTS, bs4, click, gtts-token
  Running setup.py install for gTTS
    Installing gtts-cli script to /usr/local/bin
  Could not find .egg-info directory in install record for gTTS
  Running setup.py install for bs4
  Could not find .egg-info directory in install record for bs4 (from gTTS)
  Running setup.py install for gtts-token
    warning: no files found matching 'CHANGES.txt'
  Could not find .egg-info directory in install record for gtts_token (from gTTS)
Successfully installed gTTS bs4 click gtts-token
Cleaning up...
gTTS module has installed sucesfully.
Will mark post 1 as {solved]
I think part of this problem is using a slightly outdated Linux Mint 17.3
which although updated regularly does not contain the latest packages.
Many thanks for all your repliess.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020