简体   繁体   中英

No module named 'cx_Oracle' only in CMD

my problem is with "ModuleNotFoundError: No module named 'cx_Oracle'" when I run connect_oracle.py from CMD in Windows 10.

#conncet_oracle.py

from __future__ import print_function
import os
import cx_Oracle
connection = cx_Oracle.connect("report/pass@ORA")
cursor = connection.cursor()
cursor.execute("select sysdate from dual")
today, = cursor.fetchone()
print("The current date is", today)

But:

  • when I install cx_Oracle I get

Requirement already satisfied: cx_oracle in c:\\users\\myuser\\appdata\\local\\programs\\python\\python37-32\\lib\\site-packages (7.1.0)

  • when I run connect_oracle.py in Python 3.7.2 Shell I get good result:

    exec(open('H:\\Tasks\\Python learning\\connect_oracle.py').read())

result is The current date is 2019-02-18 11:08:01

  • when I run it in Spyder I get also good result:

result is The current date is 2019-02-18 11:08:01

  • when I run print(platform.sys.version) in spyder I get:

3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)]

  • when I run version.py in CMD I get:

3.7.1 (default, Dec 10 2018, 22:09:34) [MSC v.1915 32 bit (Intel)]

  • when I run python -v in CMD I get:

Python 3.7.2

I am confuse from this all things. Is it possible that I have more version of Python and it is reason? How can I solve it?

Thank you

It was maybe my mistake, but when I run in CMD:

python connect_oracle.py

I get good result, so problem is solved, potentially.

But it is weird for me, that in CMD I can run version.py without python with good result but python connect_oracle.py can be use only with python for good result. Why?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM