ModuleNotFoundError: No module named ‘cx_Oracle‘

Source

ModuleNotFoundError: No module named 'cx_Oracle'

目录

ModuleNotFoundError: No module named 'cx_Oracle'

问题

解决

完整错误


问题

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String, DateTime, Boolean,Float


class OracleDB(object):
    Base = declarative_base()
    def __init__(self,user='xxx',password='xxx',dabatase='xxx',serverip='10.10.10.10',port='1000'):
        user = user #'root'  
        password = password 
        database = dabatase  
        serverip = serverip 
        dns = cx_Oracle.makedsn(serverip, port, service_name=dabatase)
        self.engine = create_engine("oracle://"+user+":"+password+"@" + dns, encoding='utf-8', echo=True)
        # Session = sessionmaker(bind=self.engine)
        # self.session = Session()
    def getEngine(self):
        return self.engine

解决

pip3 install cx_Oracle

完整错误

Traceback (most recent call last):
  File "dataPreProcessL.py", line 10, in <module>
    from Utils.DataPrepared.PreProcess import dataFirstProcess
  File "E:\projects\uni\uni\utils\preprocess\data.py", line 51, in <module>
    from Utils.Tools.DBUtil import OracleDB
  File "E:\projects\uni\uni\utils\tools\databaset_config.py", line 16, in <module>
    import cx_Oracle
ModuleNotFoundError: No module named 'cx_Oracle'

参考:https://stackoverflow.com/questions/48419029/modulenotfounderror-no-module-named-cx-oracle-spyder