赞
踩
系统中存在多个版本的 python 时,在使用 pip install -r requirements.txt
命令安装包时,经常会遇到 Python.h: No such file or directory
的错误,原因是对应当前 python 版本的 include 目录中没有对应的头文件导致。
笔者使用的是 uBuntu,系统自带的 python 版本为 3.6.9。后来又安装了 3.8.13 版本。但在 python 寻找的系统目录 /usr/include
下只能看到存在 python 3.6 的目录:
所以笔者在使用 python 3.8.13 安装一些包的时候会遇到 Python.h: No such file or directory
错误,原因就是没有对应的 python3.8
目录。通过如下命令来安装:
sudo apt-get install python3.8-dev
执行完成后在 /usr/include
目录下就有了 python3.8
目录,python 3.8.13 所需要的头文件 Python.h
就在该目录中。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。