Google colab Glove_Python pip 安装不起作用

Nan*_*nda 9 python pip stanford-nlp google-colaboratory

我在用

\n
! pip install glove_python\n
Run Code Online (Sandbox Code Playgroud)\n

我收到此错误消息:

\n
Collecting glove_python\n  Downloading https://files.pythonhosted.org/packages/3e/79/7e7e548dd9dcb741935d031117f4bed133276c2a047aadad42f1552d1771/glove_python-0.1.0.tar.gz (263kB)\n     |\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88\xe2\x96\x88| 266kB 16.9MB/s \nRequirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from glove_python) (1.19.5)\nRequirement already satisfied: scipy in /usr/local/lib/python3.7/dist-packages (from glove_python) (1.4.1)\nBuilding wheels for collected packages: glove-python\n  Building wheel for glove-python (setup.py) ... error\n  **ERROR: Failed building wheel for glove-python**\n  Running setup.py clean for glove-python\n  **ERROR: Failed cleaning build dir for glove-python**\nFailed to build glove-python\nInstalling collected packages: glove-python\n    Running setup.py install for glove-python ... error\n**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.\n
Run Code Online (Sandbox Code Playgroud)\n

正如下面的建议我尝试过

\n
! python -m pip install glove_python --verbose\n
Run Code Online (Sandbox Code Playgroud)\n

对于不同的成员,它输出以下重复出现的错误:

\n
has no member named \xe2\x80\x98exc_{member}\xe2\x80\x99; did you mean \xe2\x80\x98curexc_value\xe2\x80\x99?\n
Run Code Online (Sandbox Code Playgroud)\n

并以以下内容结尾:

\n
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1\n    Running setup.py install for glove-python ... error\nCleaning up...\n  Removing source in /tmp/pip-install-ru3hxbde/glove-python\nRemoved build tracker '/tmp/pip-req-tracker-ps3qzi71'\nERROR: 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.\nException information:\nTraceback (most recent call last):\n  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/cli/base_command.py", line 153, in _main\n    status = self.run(options, args)\n  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/commands/install.py", line 455, in run\n    use_user_site=options.use_user_site,\n  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/req/__init__.py", line 62, in install_given_reqs\n    **kwargs\n  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/req/req_install.py", line 888, in install\n    cwd=self.unpacked_source_directory,\n  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/utils/subprocess.py", line 275, in runner\n    spinner=spinner,\n  File "/usr/local/lib/python3.7/dist-packages/pip/_internal/utils/subprocess.py", line 242, in call_subprocess\n    raise InstallationError(exc_msg)\npip._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.\n
Run Code Online (Sandbox Code Playgroud)\n

尝试 pip install glove-python-binary 成功,但当我导入它时,出现以下错误:

\n
    import glove-python-binary\n                ^\nSyntaxError: invalid syntax\n
Run Code Online (Sandbox Code Playgroud)\n

Art*_*oul 8

看起来glove_python包很旧,它在 PIP 上的最后一次发布是在 2016 年。而且它只有源代码,所以应该由 C/C++ 编译器编译,这通常到处都有问题(需要手动安装正确的编译器和所有依赖项)。

看起来更新版本是glove-python-binary2020 年的。尝试通过安装它! pip install glove-python-binary

根据pypi 网站 glove-python-binary需要 3.6 或 3.7 或 3.8 版本的 Python,较小或较大版本的 Python 可能无法工作。

当您在 pip 中遇到任何问题或错误时,请尝试添加--verbose到 pip 命令行,这将为您打印许多有关 pip 失败原因的详细信息。

另外,正如 @GameDev所说,有时您还必须尝试运行 command! python -m pip install PACKAGE而不是! pip install PACKAGE来安装任何 Python pip 包,因为第一个命令完全使用您用来运行脚本的 python,而第二个命令可能pip从其他 Python 安装中使用,而不是从 Python 安装中使用用于稍后运行实际脚本。