1

I am trying to set up the environment variable to point to following however it gives me error

 os.environ["PATH"]= "C:\APPS\ORACLE\product\12.1.0\Client_64\Instantclient"

I get the error "Invalid character or identifier"

I am able to navigate the above path so not sure what is failing.

2 Answers 2

8

Try passing it as a raw string (no need to escape backslashes or anything else then):

 os.environ["PATH"]= r"C:\APPS\ORACLE\product\12.1.0\Client_64\Instantclient"

Note the prefixed r before the string.

Sign up to request clarification or add additional context in comments.

3 Comments

Nice! Better than my approach @Nordle :)
Thanks! But good eye for spotting where the escaping was needed :)
Please explain why escape or raw is required here!
2

You need to escape the 1 in 12

import os
os.environ["PATH"] = "C:\APPS\ORACLE\product\\12.1.0\Client_64\Instantclient"
print(os.environ['PATH'])
#C:\APPS\ORACLE\product\12.1.0\Client_64\Instantclient

1 Comment

Please explain why!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.