The Python binary you are running doesn't have cx_Oracle installed.
Install the latest version of this module. It is now called python-oracledb, see the release announcement.
Follow the installation instructions. In summary:
python -m pip install oracledb
Since you want to connect to Oracle 11g, you will need to have Oracle Client libraries installed and you will need to add a call to init_oracle_client()
(this was optional with cx_Oracle but required in what is called the 'Thick' mode of python-oracledb). From your connect string it seems your database is installed on your machine. It has the necessary Client Libraries available so you shouldn't need to install anything else. Assuming the libraries are in your PATH, then your code would be like:
import oracledb
oracledb.init_oracle_client()
conn = oracledb.connect('PAYROLL/PAYROLL@localhost:1521/XE')
print(conn.version)
Oracle DB 11 is very old and you should look at upgrading to something newer. If you have the XE edition then look at upgrading to Oracle 21c XE which is on https://www.oracle.com/database/technologies/xe-downloads.html
$ python -m site
. Do you find oracle files installed in one of those directories?cx_Oracle
module has not been installed. If you think you installed it, then it could be that there is more than one python on your system and you installed it in a different one.