How to Import a packgae in PyCharm?

 

First of all import the pacakage of pip in python console.


import pip

The below command will upgrade the version of package setuptools.

pip.main(['install','--upgrade','setuptools'])

The below command will install the scikit-learn and numpy packages.

pip.main(['install','numpy','scikit-learn'])

How to Import CX_Oracle in PyCharm?

  1. Open PyCharm and then Open your project.
  2. Click on the menu File > Settings and then the Settings window will open.
  3. In the Settings window, click on the Project node to expand and then click on the Project Interpreter.
  4. Then on the right side, click on the + button to open Available Packages window, as shown in below image. Then search for cx_Oracle in the search box. Below you will find the cx_Oracle package. Click on it to select and then click on the Install Package button as shown below.
import cx_Oracle

connection = cx_Oracle.connect("scott", "tiger", "localhost/orcl")

cursor = connection.cursor()

cursor.execute("""
    SELECT empno, ename
    FROM emp
    WHERE deptno = :did""",
    did = 30)
print("List of Employees in Department: 30")
for fempno, fename in cursor:
    print("Employee No:", fempno, "Employee Name:", fename)

Comments