gpt4 book ai didi

python - "pip install SQLAlchemy"结果在 "fatal error: Python.h: No such file or directory"

转载 作者:太空狗 更新时间:2023-10-29 17:26:34 25 4
gpt4 key购买 nike

打电话

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 扩展。

完整输出:

root@mycomputer:/# 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...
root@mycomputer:/#

Python 版本:

root@mycomputer:/#python -V
Python 2.7.3
root@mycomputer:/#

Ubuntu 版本:

root@mycomputer:/#cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"
root@mycomputer:/#

最佳答案

您需要为您的 Python 版本安装 python-dev(或类似名称)包。它包括编译 C 扩展所需的所有头文件。这些文件(不幸的是)不包含在默认的 python 包中。

对于 Ubuntu,命令是

sudo apt-get install python-dev

sudo apt-get install python3-dev

取决于您使用的版本。

关于python - "pip install SQLAlchemy"结果在 "fatal error: Python.h: No such file or directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20436528/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com