32bit and 64bit python interpreter in one project

32 Views Asked by At

In a project I have to use both 32bit and 64bit python interpreters, specifically 32bit for pyodbc library(required for older version of MS access DB) and 64bit for pandas, work could be done without pandas if there where not so much data to process. Now I am in confusion how to pull this off.

I have consulted this solution: Solution, but did not really succeeded, maybe I did something wrong.

My project structure is like this:

Project structure

when I open second_main.py(where is 32bit interpreter configured) and execute code everything works fine, code:

def test():

   fyon = "683977466"

   connection_string = (r'DRIVER={Microsoft Access Driver (*.mdb)};'
                     r'DBQ=C:\Users\Python\wtr3.mdb;')
   connection = pyodbc.connect(connection_string)
   cursor = connection.cursor()

   data = cursor.execute("select * from SolvedErrors where Ref = ?", fyon).fetchall()

   cursore.close()
   connection.close()

   return data

print(test())

But when I import second_main.py in main.py(here is 64bit interpreter configured for pandas, that would use that data obtained from second_main.test() and further process it) it executes function with 64bit interpreter and therefore raises error. Is there a way to solve this problem? Is there a way maybe to run that .py file independently with subprocess and appropriate python interpreter and capture return value of function, but to retain original data type of return statement? Or any other idea?

Thanks in advanced?

0

There are 0 best solutions below