今天在腾讯云GPU服务器上安装transformers时安装报错,报错信息部分信息如下:
regex_3/_regex.c:26329:12: warning: ‘return’ with a value, in function returning void
return m;
^
regex_3/_regex.c:26230:16: note: declared here
PyMODINIT_FUNC PyInit__regex(void) {
^~~~~~~~~~~~~
regex_3/_regex.c: At top level:
regex_3/_regex.c:26217:27: error: storage size of ‘regex_module’ isn’t known
static struct PyModuleDef regex_module = {
^~~~~~~~~~~~
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-3ziwxS/regex/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-xAk0QC-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-3ziwxS/regex/
可以从报错信息这一句== error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1 ==看出是使用gcc进行编译时程序出错,错误问题是** regex_3/_regex.c:26217:27: error: storage size of ‘regex_module’ isn’t known **,每个人报错的信息可能不一样,结合我百度查找的资料可以归类为以下几种问题:
-
缺乏一些包需要的dev环境
- 解决方法:
sudo apt-get install libssl-dev libffi-dev python-dev build-essential libxml2-dev libxslt1-dev
-
缺乏一些.h头文件,如 ** fatal error:xxxx.h: No such file or directory**
- 解决方法,去找对应包含这些头文件的dev文件,先install这些环境,再重新install这个包,ubuntu系统的可以去这个网站找:ubuntu
-
编译环境不对应,例如安装的是python2.几的版本,但是安装的确实python3的dev环境,笔者就是这个问题,两个解决方案:
- 第一种:
使用python3重新安装
#如果你使用的是conda conda create -n yourenvname python==3.x #创建新的虚拟环境 conda activate yourenvname #激活虚拟环境 pip install xxx #重新安装 #如果使用的是自带的python卸载重新安装就行
- 第二种:
首先查看python版本
python --version
安装python2.x-dev(x表示你对应的版本)
sudo apt-get install python2.x-dev
- 第一种: