MacOS安装python glove库踩坑经验
MacOS安装python glove库踩坑经验碰到的问题踩坑1 安装gcc踩坑2 试图舍近求远使用anaconda碰到的问题课程需要使用glove库,手上的windows电脑这两天又送修了,只能在mac上安装python的相关环境。其他倒是都没有问题,在使用pip3 install glove-python的时候碰到如下问题(base) ➜~ pip3 install glove-pythonC
MacOS安装python glove库踩坑经验
碰到的问题
课程需要使用glove库,手上的windows电脑这两天又送修了,只能在mac上安装python的相关环境。其他倒是都没有问题,在使用pip3 install glove-python
的时候碰到如下问题
(base) ➜ ~ pip3 install glove-python
Collecting glove-python
Using cached glove_python-0.1.0.tar.gz (263 kB)
Requirement already satisfied: numpy in ./anaconda3/lib/python3.8/site-packages (from glove-python) (1.20.1)
Requirement already satisfied: scipy in ./anaconda3/lib/python3.8/site-packages (from glove-python) (1.6.2)
Building wheels for collected packages: glove-python
Building wheel for glove-python (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /Users/admin/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-wheel-h9nj2cq8
cwd: /private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5/
Complete output (16 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.8
creating build/lib.macosx-10.9-x86_64-3.8/glove
copying glove/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/glove
copying glove/glove.py -> build/lib.macosx-10.9-x86_64-3.8/glove
copying glove/corpus.py -> build/lib.macosx-10.9-x86_64-3.8/glove
running build_ext
building 'glove.glove_cython' extension
creating build/temp.macosx-10.9-x86_64-3.8
creating build/temp.macosx-10.9-x86_64-3.8/glove
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/admin/anaconda3/include -arch x86_64 -I/Users/admin/anaconda3/include -arch x86_64 -I/Users/admin/anaconda3/include/python3.8 -c glove/glove_cython.c -o build/temp.macosx-10.9-x86_64-3.8/glove/glove_cython.o -fopenmp -ffast-math -march=native
clang: error: unsupported option '-fopenmp'
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for glove-python
Running setup.py clean for glove-python
ERROR: Command errored out with exit status 1:
command: /Users/admin/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' clean --all
cwd: /private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5
Complete output (6 lines):
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: option --all not recognized
----------------------------------------
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:
command: /Users/admin/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-record-xqhqx2mu/install-record.txt --single-version-externally-managed --compile --install-headers /Users/admin/anaconda3/include/python3.8/glove-python
cwd: /private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5/
Complete output (8 lines):
running install
running build
running build_py
running build_ext
building 'glove.glove_cython' extension
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/admin/anaconda3/include -arch x86_64 -I/Users/admin/anaconda3/include -arch x86_64 -I/Users/admin/anaconda3/include/python3.8 -c glove/glove_cython.c -o build/temp.macosx-10.9-x86_64-3.8/glove/glove_cython.o -fopenmp -ffast-math -march=native
clang: error: unsupported option '-fopenmp'
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /Users/admin/anaconda3/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5/setup.py'"'"'; __file__='"'"'/private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-install-2fe6uukp/glove-python_8391e48580964dc2926dbe627d33d1a5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-record-xqhqx2mu/install-record.txt --single-version-externally-managed --compile --install-headers /Users/admin/anaconda3/include/python3.8/glove-python Check the logs for full command output.
主要报错就是command 'gcc' failed with exit status 1
踩坑1 安装gcc
因为报错是gcc的error,发现电脑上并没有安装gcc,于是brew install gcc
安装得到gcc 11.1.0
之后出现报错clang: error: unsupported option '-fopenmp'
,故再去安装clang-omp,报错:
Error: No available formula with the name "clang-omp"
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
==> Searching local taps...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
好家伙,原来clang-omp被迁移到了llvm(这实在太麻烦了,违背作者的懒狗原则,故放弃)
踩坑2 试图舍近求远使用anaconda
看到stackoverflow上有朋友说glove只支持3.5以下的python,低头一看自己是个3.7,于是寻求包管理工具的帮助。
先是去brew install pyenv
,可怜地发现已经不支持新版的osx了,只能卑微向anaconda低头。
以前使用过anaconda的管理工具,但是觉得体量过大,一直很抗拒安装。但事已至此,希望conda能救一条老命。
安装anaconda bash的教程网上很多,主要问题出在了镜像源……
UnavailableInvalidChannel: The channel is not accessible or is invalid.
好家伙一直以来用的清华镜像源似乎出现了问题,一搜发现
替换成中科大的镜像源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/osx-64
conda config --add https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/osx-64
好嘛,再次试图install glove
➜ ~ conda install python-glove
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- python-glove
Current channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/free/osx-64
- https://mirrors.ustc.edu.cn/anaconda/pkgs/free/noarch
- https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/osx-64
- https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/noarch
- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
查一查发现镜像源里根本没有glove这个库(也有可能是懒狗作者的操作不太正常)
换github源
继续在csdn/stackoverflow上寻找可能的解决方案,发现glove的安装在很多windows电脑上可能出现问题,但macos的解决方案基本没有……
参考了一位博主在windows上的解决方案(https://blog.csdn.net/weixin_45072810/article/details/109783520)
现在似乎是成功安装了
(base) ➜ ~ pip3 install https://github.com/JonathanRaiman/glove/archive/master.zip
Collecting https://github.com/JonathanRaiman/glove/archive/master.zip
Downloading https://github.com/JonathanRaiman/glove/archive/master.zip
\ 5.7 kB 8.9 MB/s
Requirement already satisfied: cython in ./anaconda3/lib/python3.8/site-packages (from glove==1.0.1) (0.29.23)
Requirement already satisfied: numpy in ./anaconda3/lib/python3.8/site-packages (from glove==1.0.1) (1.20.1)
Building wheels for collected packages: glove
Building wheel for glove (setup.py) ... done
Created wheel for glove: filename=glove-1.0.1-py3-none-any.whl size=4998 sha256=333928882f3857f80c341cdc50829d89e47fc7dcd58858ab03f5a68df490484d
Stored in directory: /private/var/folders/zb/bs3jp5756wx8bll4dj2bhg7w0000gp/T/pip-ephem-wheel-cache-nnihzarf/wheels/1c/f6/cf/371de84d071993d3402708a47a204d3022675d5761f8bf4b62
Successfully built glove
Installing collected packages: glove
Successfully installed glove-1.0.1
总结
踩坑过于严重……
更多推荐
所有评论(0)