Google colab Glove_Python pip install not working
Asked Answered
A

3

9

I am using

! pip install glove_python

I'm getting this error message:

Collecting glove_python
  Downloading https://files.pythonhosted.org/packages/3e/79/7e7e548dd9dcb741935d031117f4bed133276c2a047aadad42f1552d1771/glove_python-0.1.0.tar.gz (263kB)
     |████████████████████████████████| 266kB 16.9MB/s 
Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from glove_python) (1.19.5)
Requirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from glove_python) (1.4.1)
Building wheels for collected packages: glove-python
  Building wheel for glove-python (setup.py) ... error
  **ERROR: Failed building wheel for glove-python**
  Running setup.py clean for glove-python
  **ERROR: Failed cleaning build dir for glove-python**
Failed to build glove-python
Installing collected packages: glove-python
    Running setup.py install for glove-python ... error
**ERROR: Command errored out with exit status 1**: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-nypxp28t/glove-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-nypxp28t/glove-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-cnn32mbr/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

As suggested below I tried

! python -m pip install glove_python --verbose

Which outputs the following recurring error with different members:

has no member named ‘exc_{member}’; did you mean ‘curexc_value’?

And ends with:

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Running setup.py install for glove-python ... error
Cleaning up...
  Removing source in /tmp/pip-install-ru3hxbde/glove-python
Removed build tracker '/tmp/pip-req-tracker-ps3qzi71'
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ru3hxbde/glove-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ru3hxbde/glove-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ywzvlm5m/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
Exception information:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/base_command.py", line 153, in _main
    status = self.run(options, args)
  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/commands/install.py", line 455, in run
    use_user_site=options.use_user_site,
  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/req/__init__.py", line 62, in install_given_reqs
    **kwargs
  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/req/req_install.py", line 888, in install
    cwd=self.unpacked_source_directory,
  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/utils/subprocess.py", line 275, in runner
    spinner=spinner,
  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/utils/subprocess.py", line 242, in call_subprocess
    raise InstallationError(exc_msg)
pip._internal.exceptions.InstallationError: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ru3hxbde/glove-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ru3hxbde/glove-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ywzvlm5m/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

Trying pip install glove-python-binary is successful but when I import it I get the following error:

    import glove-python-binary
                ^
SyntaxError: invalid syntax
Agricola answered 27/2, 2021 at 6:11 Comment(7)
Try doing python -m pip install glove_pythonLumumba
@GameDev it returns an invalid syntax error on Google Colab :/Agricola
@Agricola Command of comment from GameDev above should be done with ! prefix. Also please try adding --verbose to pip command, what it outputs? It should give lots of details regarding reason of error.Roquelaure
@Roquelaure thank you! I ran it as GameDev suggested but with --verbose and added the output to my question above :)Agricola
@Agricola After pip-installing glove-python-binary you have to import glove in your code. It often happens that module name inside import is different from module name in PIP, they're not obligatory same.Roquelaure
@Roquelaure Ah! Oh man, thank you so much for walking me through this; its up and running now. You're a gentleman and a scholar Arty!Agricola
No answers in the question, please. I have rolled back/edited your question and removed the answer. Add the answer in the answer section only.Adrell
R
8

Seems like glove_python package is very old, last relese of it on PIP was in 2016. And it has only sources there, so should be compiled by C/C++ compiler, which is usually problematic everywhere (needs manual installing correct compiler and all dependencies).

Looks like updated version is glove-python-binary it dates to 2020. Try installing it through ! pip install glove-python-binary.

According to pypi site glove-python-binary needs Python of versions 3.6 or 3.7 or 3.8, smaller or bigger version of Python will not probably work.

When you have any problem or error in pip try adding --verbose to pip command line, this will print you a lot of details about reasons of pip failure.

Also as @GameDev said sometimes you have to also try running command ! python -m pip install PACKAGE instead of ! pip install PACKAGE, to install any Python pip PACKAGE, because first command uses exactly python that you use to run the script, while second may use pip from other Python installation, not from Python installation that is used to run actual script later.

Roquelaure answered 27/2, 2021 at 10:13 Comment(0)
C
3

In the google-colab just write:

!pip install glove-python-binary

And for using, do this:

import glove 

For example:

from glove import Glove
from glove import Corpus

This worked for me!

Crusted answered 19/4, 2022 at 5:25 Comment(0)
C
0

I tried all the above options but none of them worked. What worked for me was ! pip install glove-python3. This was for python 3.10.12.

Cosmic answered 5/4 at 12:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.