尝试安装pyodbc:pip install pyodbc
它出现以下错误。我专门安装了一个不同的项目peewee
,它安装时没有给我错误。我进一步尝试了pip install pymssql
,它也出现了类似的错误。我熟悉pyodbc
并希望在我的烧瓶应用程序中使用它。
任何人都知道如何克服这个错误。
我关注UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 13: ordinal not in range(128),How to fix: "UnicodeDecodeError: 'ascii' codec can't decode byte"但无法解决问题。
我使用的是ubuntu 14.05。
pip install pyodbc
Downloading/unpacking pyodbc
Downloading pyodbc-3.0.10.tar.gz (68kB): 68kB downloaded
Running setup.py (path:/tmp/pip-build-xNSuOb/pyodbc/setup.py) egg_info for package pyodbc
warning: no files found matching 'tests/*'
warning: no files found matching 'README.rst'
Installing collected packages: pyodbc
Running setup.py install for pyodbc
building 'pyodbc' extension
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall - Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC - DPYODBC_VERSION=3.0.10 -DPYODBC_UNICODE_WIDTH=4 -DSQL_WCHART_CONVERT=1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include -I/usr/include/python2.7 -c /tmp/pip-build-xNSuOb/pyodbc/src/params.cpp -o build/temp.linux-x86_64-2.7/tmp/pip-build-xNSuOb/pyodbc/src/params.o -Wno-write-strings
x86_64-linux-gnu-gcc: error: unrecognized command line option ‘-fstack-protector-strong’
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-xNSuOb/pyodbc/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-GvPtxS-record/install-record.txt --single-version-externally-managed --compile --user:
running install
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/tmp
creating build/temp.linux-x86_64-2.7/tmp/pip-build-xNSuOb
creating build/temp.linux-x86_64-2.7/tmp/pip-build-xNSuOb/pyodbc
creating build/temp.linux-x86_64-2.7/tmp/pip-build-xNSuOb/pyodbc/src
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict- prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector- strong -Wformat -Werror=format-security -fPIC -DPYODBC_VERSION=3.0.10 - DPYODBC_UNICODE_WIDTH=4 -DSQL_WCHART_CONVERT=1 - I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include -I/usr/include/python2.7 -c /tmp/pip-build-xNSuOb/pyodbc/src/params.cpp -o build/temp.linux-x86_64-2.7/tmp/pip-build-xNSuOb/pyodbc/src/params.o -Wno-write-strings
x86_64-linux-gnu-gcc: error: unrecognized command line option ‘- fstack-protector-strong’
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build- xNSuOb/pyodbc/setup.py';exec(compile(getattr(tokenize, 'open', open) (__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install -- record /tmp/pip-GvPtxS-record/install-record.txt --single-version- externally-managed --compile --user failed with error code 1 in /tmp/pip- build-xNSuOb/pyodbc
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 248, in main
return command.main(cmd_args)
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 66: ordinal not in range(128)
答案 0 :(得分:0)
问题很可能是你正在使用的古老点 - 1.5.6。使用pip install -U pip
将其升级到最新版本并再次检查。
另外,请确保安装了python-devel。
答案 1 :(得分:0)
感谢您的帮助。一个懒散页面上的朋友帮助我完成了它。
export LC_ALL=C
这会使pip使用操作系统中的本地配置。pip install --upgrade setuptools
pip install pyodbc
并出现以下错误但不再是ascii
问题 fatal error: sql.h: No such file or directory #include <sql.h> ^compilation terminated.error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
然后我们想出了gcc编译器的第二个问题,因为pyodbc是用C语言编写的。
这最终解决了它
4.run sudo apt-get install unixodbc-dev && sudo apt-get install pyodbc
谢谢大家的答案。