Подтвердить что ты не робот

"pip install SQLAlchemy" Результаты в "фатальной ошибке: Python.h: нет такого файла или каталога"

Вызов

pip install SQLAlchemy

Я получаю сообщение об ошибке:

lib/sqlalchemy/cextension/processors.c:10:20: fatal error: Python.h: No such file or directory

Насколько я знаю, у меня есть правильная версия Python (2.7.3) и ОС (Ubuntu 12.04) (см. ниже), чтобы это работало. Я делаю что-то неправильно?

Установка работает как

pip install --global-option='--without-cextensions' SQLAlchemy"

но я хочу расширения C.

Полный вывод:

[email protected]:/# pip install SQLAlchemy
Downloading/unpacking SQLAlchemy
  Downloading SQLAlchemy-0.8.3.tar.gz (3.9Mb): 3.9Mb downloaded
  Running setup.py egg_info for package SQLAlchemy

    warning: no files found matching '*.jpg' under directory 'doc'
    no previously-included directories found matching 'doc/build/output'
Installing collected packages: SQLAlchemy
  Running setup.py install for SQLAlchemy
    building 'sqlalchemy.cprocessors' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c lib/sqlalchemy/cextension/processors.c -o build/temp.linux-x86_64-2.7/lib/sqlalchemy/cextension/processors.o
    lib/sqlalchemy/cextension/processors.c:10:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    ***************************************************************************
    command 'gcc' failed with exit status 1
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Failure information, if any, is above.
    Retrying the build without the C extension now.
    ***************************************************************************

    warning: no files found matching '*.jpg' under directory 'doc'
    no previously-included directories found matching 'doc/build/output'
    ***************************************************************************
    WARNING: The C extension could not be compiled, speedups are not enabled.
    Plain-Python build succeeded.
    ***************************************************************************
Successfully installed SQLAlchemy
Cleaning up...
[email protected]:/#

Версия Python:

[email protected]:/#python -V
Python 2.7.3
[email protected]:/#

Версия Ubuntu:

[email protected]:/#cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"
[email protected]:/#
4b9b3361

Ответ 1

Вам нужно установить пакет python-dev (или подобное имя) для вашей версии Python. Он включает в себя все файлы заголовков, необходимые для компиляции расширений C. Эти файлы (к сожалению) не включены в пакеты python по умолчанию.

Для Ubuntu команда

sudo apt-get install python-dev

или

sudo apt-get install python3-dev

в зависимости от того, какую версию вы используете.

Ответ 2

sudo apt-get install python-dev -y