【问题标题】:Google colab Glove_Python pip install not workingGoogle colab Glove_Python pip 安装不起作用
【发布时间】:2021-05-29 10:35:18
【问题描述】:

我正在使用

! pip install glove_python

我收到此错误消息:

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.

如下所示,我尝试过

! python -m pip install glove_python --verbose

这会输出以下针对不同成员的重复错误:

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

结尾是:

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.

尝试 pip install glove-python-binary 是成功的,但是当我导入它时,我收到以下错误:

    import glove-python-binary
                ^
SyntaxError: invalid syntax

【问题讨论】:

  • 试试python -m pip install glove_python
  • @GameDev 它在 Google Colab 上返回一个无效的语法错误:/
  • @NandaPanda 来自 GameDev 的评论命令应使用 ! 前缀。另外请尝试将--verbose 添加到 pip 命令中,它会输出什么?它应该提供很多关于错误原因的详细信息。
  • @Arty 谢谢!我按照 GameDev 的建议运行它,但使用 --verbose 并将输出添加到我上面的问题中:)
  • @NandaPanda 在 pip 安装 glove-python-binary 之后,您必须在代码中添加 import gloveimport 中的模块名称与 PIP 中的模块名称经常发生不同,它们不一定相同。

标签: python pip google-colaboratory stanford-nlp


【解决方案1】:

好像glove_python 包很老了,PIP 上的最后一个版本是 2016 年。而且它只有源代码,所以应该由 C/C++ 编译器编译,这通常到处都有问题(需要手动安装正确)编译器和所有依赖项)。

看起来更新版本是glove-python-binary,它可以追溯到 2020 年。尝试通过! pip install glove-python-binary 安装它。

根据pypi siteglove-python-binary需要3.6或3.7或3.8版本的Python,更小或更大版本的Python可能都行不通。

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

还有@GameDev said 有时您还必须尝试运行命令! python -m pip install PACKAGE 而不是! pip install PACKAGE 来安装任何Python pip PACKAGE,因为第一个命令使用的正是您用来运行脚本的python,而第二个可以使用来自其他 Python 安装的pip,而不是来自用于稍后运行实际脚本的 Python 安装。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-23
    • 2018-10-19
    • 1970-01-01
    • 2018-11-20
    • 1970-01-01
    • 2018-07-03
    • 2014-08-29
    • 2020-12-11
    相关资源
    最近更新 更多