Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 96-97: invalid continuation byte #65

Closed
shaoeChen opened this issue Aug 18, 2017 · 12 comments

Comments

@shaoeChen
Copy link

For general questions:

i had success to use cx_Oracle 5.3+Python 32bit before!
now i reinstall my python from 3.6 32bit to 3.6 64bit, and use cx_Oralce6.0 !
i try to install it from pypi, and try to install by using pip install cx_Oracle,
both the same question
i can import cx_Oracle
but while i use cx_Oracle.connect then it's error ,the error message:
UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 96-97: invalid continuation byte

Answer the following questions:

  1. What is your version of Python? Is it 32-bit or 64-bit?
    Python 3.6 64bit

  2. What is your version of cx_Oracle?
    6.0

  3. What is your version of the Oracle client (e.g. Instant Client)? How was it
    installed? Where is it installed?
    11g

  4. What is your version of the Oracle Database?
    11g

  5. What is your OS and version?
    windows 7 64bit

  6. What compiler version did you use? For example, with GCC, run
    gcc --version.
    i just use cmd to run python

  7. What environment variables did you set? How exactly did you set them?

  8. What exact command caused the problem (e.g. what command did you try to
    install with)? Who were you logged in as?
    cx_Oracle.connect('count', 'password', 'oracleclient')

  9. What error(s) you are seeing?
    UnicodeDecodeError: 'utf-8' codec can't decode bytes in position 96-97: invalid
    continuation byte

@anthony-tuininga
Copy link
Member

If you changed to a 64-bit Python, you will also need to change to a 64-bit Oracle client. The message you got looks similar to one from an older version of cx_Oracle 6.0. Can you check to see what version of cx_Oracle you are using, too?

@shaoeChen
Copy link
Author

dear..
Thank you for the prompt reply.
cx_Oracle i sure i install 6.0
image
and i have install 64 bit oracle client!
i try to check my environment path as the pic
image
and oracle defualt encode is utf8
image
and my python default encode is utf8
image
thanks for your help!

@anthony-tuininga
Copy link
Member

Looks like your 32-bit 11g installation is first in the path? You need to make sure your 64-bit Oracle client is first in the path. You sure seem to have a lot of different Oracle clients, too! Can you also set the environment variable DPI_DEBUG_LEVEL=31 and try running the code again?

@shaoeChen
Copy link
Author

dear..
i try to follow your direction
to change path put 64bit before 32bit and DPI_DEBUG_LEVEL=31!
but still the same message!
image

@shaoeChen
Copy link
Author

by the way,
for job , my computer had install so many version oracle clients.........0rz

@anthony-tuininga
Copy link
Member

Are you using Python from the command prompt? Or some form of IDE?

@anthony-tuininga
Copy link
Member

Also, the connection parameters don't look valid. Can you use those parameters to connect to the database using SQL*Plus?

@shaoeChen
Copy link
Author

i use python from pycharm and command !
i know the connection parameters is wrong, i just demo to show the error message.
but even no parameters, it still wrong!
parameter1:count
parameter2:pwd
parameter3:db
but......
now i don't konw what's happen.. i can connect oracle...
i don't do anything but it's success~~~~~surprise
thanks for your help , i think maybe change the path need wait a moment...i guess
really thank you very much
image

@anthony-tuininga
Copy link
Member

If you changed the PATH environment variable in the GUI, you have to restart your command prompt or PyCharm before it will take effect. Perhaps that was the source of your issue? I'd still like to know why you got the error message you did. If you are able to run Python from the command prompt using the old invalid PATH and with DPI_DEBUG_LEVEL=31 and provide the output you get, that would be very helpful. Thanks!

@shaoeChen
Copy link
Author

dear sir..
sorry too late to come back!
i remember i close the command and open again then success after follow your direction to change path.
but i still can't sure it's the reason or not!
all my operation very easy.
after download cx_Oracle from pypi then i install it python -m pip install cx_oraclexxxxx
then open command
fist i import the cx_Oracle
second db = cx_Oracle.connect('Count','Pwd','DB')
then the error message show!
just only!
hope it's helpful , and thank you create a nice lib to use !

@anthony-tuininga
Copy link
Member

Ok. Thanks for your help.

@douqq
Copy link

douqq commented May 23, 2018

I had this problem and here is my solution:
check the oracle client folder if it is green color(windows server).If so, this folder may be encrypted , you can unlock it and it's descent folder in property-advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants