Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google colab Glove_Python pip install not working

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
like image 873
NandaPanda Avatar asked Feb 27 '21 06:02

NandaPanda


2 Answers

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.

like image 176
Arty Avatar answered Oct 13 '22 12:10

Arty


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!

like image 33
Yousef Alizadeh Avatar answered Oct 13 '22 12:10

Yousef Alizadeh