0

Trying to install pyodbc: pip install pyodbc it got the following error. I install a different item peewee specifically and it install without giving me error. I further tried with pip install pymssql and it also came with a similar error. I am familiar with pyodbc and would like to use it in my flask app.

Anyone with an idea how i can overcome this error.

i followed 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" but could not solve the problem.

I am using 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)
Community
  • 1
  • 1
saviour123
  • 1,095
  • 2
  • 13
  • 21

2 Answers2

0

Most likely the problem is ancient pip you are using - 1.5.6. Upgrade it to the latest with pip install -U pip and check again.

Also, make sure that python-devel is installed.

Lukasz Tracewski
  • 10,794
  • 3
  • 34
  • 53
0

Thanks for the Help. A friend on one slack page help me through it.

  1. export LC_ALL=C this would make pip use the local configuration within the operating system.
  2. and pip install --upgrade setuptools
  3. pip install pyodbc again and have the following error But no longer the ascii issue

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 We then figured out the second problem to be with gcc compiler since pyodbc was written in C.

And this finally this solved it

4.run sudo apt-get install unixodbc-dev && sudo apt-get install pyodbc

thank you all for the answers.

Hudson Santos
  • 155
  • 10
saviour123
  • 1,095
  • 2
  • 13
  • 21