django 中安装 pyodbc,报错 warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ 该如何解决?

2018-07-02 12:29:43 +08:00
 panghua

django 中安装 pyodbc 和,报错如下: Collecting pyodbc==4.0.23 Using cached https://files.pythonhosted.org/packages/aa/71/cef225c4889620a1a00251d24c1746fe0cf4124290a75d1c2dc5c187b61f/pyodbc-4.0.23.tar.gz Building wheels for collected packages: pyodbc Running setup.py bdist_wheel for pyodbc ... error Complete output from command /home/python/venv/healthcloud/venv/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-r8lp4myx/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/pip-wheel-cwzrptx8 --python-tag cp35: running bdist_wheel running build running build_ext building 'pyodbc' extension creating build creating build/temp.linux-x86_64-3.5 creating build/temp.linux-x86_64-3.5/src x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-0lXFsV/python3.5-3.5.4~rc1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=4.0.23 -I/usr/include/python3.5m -I/home/python/venv/healthcloud/venv/include/python3.5m -c src/pyodbcmodule.cpp -o build/temp.linux-x86_64-3.5/src/pyodbcmodule.o -Wno-write-strings cc1plus: warning: command line option ‘-Wstrict-prototypes ’ is valid for C/ObjC but not for C++ In file included from src/pyodbcmodule.cpp:11:0: src/pyodbc.h:45:10: fatal error: Python.h: 没有那个文件或目录 #include <Python.h> ^~~~~~~~~~ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1


Failed building wheel for pyodbc Running setup.py clean for pyodbc Failed to build pyodbc Installing collected packages: pyodbc Running setup.py install for pyodbc ... error Complete output from command /home/python/venv/healthcloud/venv/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-r8lp4myx/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-oz_hthuf/install-record.txt --single-version-externally-managed --compile --install-headers /home/python/venv/healthcloud/venv/include/site/python3.5/pyodbc: running install running build running build_ext building 'pyodbc' extension creating build creating build/temp.linux-x86_64-3.5 creating build/temp.linux-x86_64-3.5/src x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-0lXFsV/python3.5-3.5.4~rc1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DPYODBC_VERSION=4.0.23 -I/usr/include/python3.5m -I/home/python/venv/healthcloud/venv/include/python3.5m -c src/pyodbcmodule.cpp -o build/temp.linux-x86_64-3.5/src/pyodbcmodule.o -Wno-write-strings cc1plus: warning: command line option ‘-Wstrict-prototypes ’ is valid for C/ObjC but not for C++ In file included from src/pyodbcmodule.cpp:11:0: src/pyodbc.h:45:10: fatal error: Python.h: 没有那个文件或目录 #include <Python.h> ^~~~~~~~~~ compilation terminated. error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/home/python/venv/healthcloud/venv/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-r8lp4myx/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-oz_hthuf/install-record.txt --single-version-externally-managed --compile --install-headers /home/python/venv/healthcloud/venv/include/site/python3.5/pyodbc" failed with error code 1 in /tmp/pip-install-r8lp4myx/pyodbc/

4269 次点击
所在节点    问与答
2 条回复
panghua
2018-07-02 12:31:03 +08:00
用 Python3 版本
panghua
2018-07-02 13:15:29 +08:00
已经解决:
sudo apt install python3-pip
sudo apt install unixodbc-dev
sudo pip3 install pyodbc
就三步

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/467436

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX