ubuntu 如何在没有 root 访问权限的情况下 pip 安装 PyYAML 等编译库
How to pip install compiled libraries like PyYAML without root access on ubuntu
我很难安装/编译 Python 模块 PyYAML。我在一个受限的 linux 环境中工作(Ubuntu 14.04,我 没有 有根)。我不认为这个问题是 PyYAML 独有的,因为它是我需要的第一个需要 gcc
扩展才能构建的库。
我已设法 apt-get
用户文件夹中的以下包,因为我无法写入根拥有的文件夹,但如果更有意义,可以尝试其他文件夹。
- python2.7-dev
- python3-开发
我修改了一些环境变量,使我能够获得部分可操作的 python 环境。 apt-get
目标安装是 ${DEPS_DIR}/apt
:
export PYTHONHOME="${DEPS_DIR}/apt/usr"
export PYTHONIOENCODING=utf8
export CPATH="${DEPS_DIR}/apt/usr/include/python2.7:${DEPS_DIR}/apt/usr/include"
export PATH="${DEPS_DIR}/apt/usr/local/bin"
我怀疑我遗漏了一个或多个变量,或者路径顺序错误,无法正常运行。大多数在 SO 上搜索我看到的问题都是理所当然的,你可以 sudo
安装。
这是我在尝试 pip install PyYAML
:
时看到的特定错误
In file included from ext/_yaml.h:2:0,
from ext/_yaml.c:271: /usr/include/yaml.h:633:1: note: expected ‘yaml_char_t *’ but argument is of type ‘char *’
yaml_mapping_start_event_initialize(yaml_event_t *event, ^
x86_64-linux-gnu-gcc: internal compiler error: Killed (program cc1)
Please submit a full bug report, with preprocessed source if
appropriate. See for
instructions. error: command 'x86_64-linux-gnu-gcc' failed with exit
status 4
我使用的是 pip -V
9.0.1,python -V
是 2.7.6。我试图一次性安装 virtualenv 和 wrapper,但似乎并没有像我在笔记本电脑上那样真正让它工作。
对于一些比较麻烦的python依赖,通常会有额外的包可以在本地安装,以避免一些扩展编译问题。
这两个库都有免编译的系统包:
apt-get python-yaml
apt-get python-websocket
我很难安装/编译 Python 模块 PyYAML。我在一个受限的 linux 环境中工作(Ubuntu 14.04,我 没有 有根)。我不认为这个问题是 PyYAML 独有的,因为它是我需要的第一个需要 gcc
扩展才能构建的库。
我已设法 apt-get
用户文件夹中的以下包,因为我无法写入根拥有的文件夹,但如果更有意义,可以尝试其他文件夹。
- python2.7-dev
- python3-开发
我修改了一些环境变量,使我能够获得部分可操作的 python 环境。 apt-get
目标安装是 ${DEPS_DIR}/apt
:
export PYTHONHOME="${DEPS_DIR}/apt/usr"
export PYTHONIOENCODING=utf8
export CPATH="${DEPS_DIR}/apt/usr/include/python2.7:${DEPS_DIR}/apt/usr/include"
export PATH="${DEPS_DIR}/apt/usr/local/bin"
我怀疑我遗漏了一个或多个变量,或者路径顺序错误,无法正常运行。大多数在 SO 上搜索我看到的问题都是理所当然的,你可以 sudo
安装。
这是我在尝试 pip install PyYAML
:
In file included from ext/_yaml.h:2:0, from ext/_yaml.c:271: /usr/include/yaml.h:633:1: note: expected ‘yaml_char_t *’ but argument is of type ‘char *’ yaml_mapping_start_event_initialize(yaml_event_t *event, ^ x86_64-linux-gnu-gcc: internal compiler error: Killed (program cc1) Please submit a full bug report, with preprocessed source if appropriate. See for instructions. error: command 'x86_64-linux-gnu-gcc' failed with exit status 4
我使用的是 pip -V
9.0.1,python -V
是 2.7.6。我试图一次性安装 virtualenv 和 wrapper,但似乎并没有像我在笔记本电脑上那样真正让它工作。
对于一些比较麻烦的python依赖,通常会有额外的包可以在本地安装,以避免一些扩展编译问题。
这两个库都有免编译的系统包:
apt-get python-yaml
apt-get python-websocket