【问题标题】:Linux : unable to install kivy in virtual environmentLinux:无法在虚拟环境中安装 kivy
【发布时间】:2017-02-26 13:39:40
【问题描述】:

我正在使用 python2.7 并创建了一个虚拟环境“kivyenv”。 首先我安装 Cython,然后在 kivyenv 中安装 kivy。

pip install Cython
pip install kivy

kivy 安装失败,出现一些错误:-

In file included from /tmp/pip-build-4T9oG4/kivy/kivy/graphics/opengl.c:274:0:
/tmp/pip-build-4T9oG4/kivy/kivy/graphics/gl_redirect.h:43:22: fatal error: GL/gl.h: No such file or directory
 #   include <GL/gl.h>
                      ^
compilation terminated.
 error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Command "/root/kivyenv/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-4T9oG4/kivy/setup.py';
exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" 
install --record /tmp/pip-3__DxE-record/install-record.txt --single-version-externally-managed --compile --install-headers
 /root/kivyenv/include/site/python2.7/kivy" failed with error code 1 in /tmp/pip-build-4T9oG4/kivy/

我使用的是 Ubuntu 16。

【问题讨论】:

  • 你安装了 setuptools 吗?
  • 看来你需要在虚拟环境中使用 OpenGL 源代码(或至少 C/C++ 头文件 *.h)
  • 我可以使用任何命令来安装这些吗? @furas
  • 在 Ubuntu 中一如既往地使用apt-getapt(命令行)或synaptic(GUI)或aptitude(文本UI)

标签: python linux python-2.7 virtualenv kivy


【解决方案1】:

有同样的问题。以下对我有用:

pip(3) install Cython==0.26

pip(3) install kivy

希望对你有帮助

【讨论】:

  • 这就是为什么 3 在括号中。对于 python 2.7 pip 应该可以为使用 python 3 时可能遇到问题的任何人添加 (3)。*
【解决方案2】:

发生这种情况是因为您的系统上没有安装依赖库,特别是 OpenGL 的依赖库 - 很可能您没有安装 mesa 包。

按照您的特定发行版的说明安装所有需要的依赖项:https://kivy.org/docs/installation/installation-linux.html#using-software-packages

【讨论】:

    猜你喜欢
    • 2018-01-30
    • 2018-04-19
    • 2017-04-10
    • 2019-04-27
    • 2018-02-20
    • 1970-01-01
    • 1970-01-01
    • 2023-03-29
    • 2018-12-02
    相关资源
    最近更新 更多