2

My main app is running with Python3

I have a crucial package that I need to install which only support Python2...

I'm running on windows

I thought of maybe setting this package on another virtual environment in addition to a flask server to be used for communication.

Is there another way to pipe messages between apps beside a server?

Is there a better way to go for Python2, Python3 mix?

Edgar Barber
  • 345
  • 3
  • 13
  • maybe ask about the packages you're using... there might be alternatives to the package or maybe alternatives to the packages that are forcing you to use python 3 – AntiMatterDynamite Jun 17 '18 at 07:56

3 Answers3

6

How about using the subprocess module. You can start the Python 2 program as a subprocess of your Python 3 app. They can communicate via the subprocess PIPE.

malukas
  • 106
  • 3
1

Flask is too heavy. Why not use socket and selectors? offical example

Rouzip
  • 101
  • 3
0

Unfortunately, I got the similar problem lately and would like to share my solution. I used multiprocssing.connection module. The default pickling protocol should be changed when sending the data from Python 3 to Python 2. The way to change the default pickling protocol is described in this answer.

Slaven Glumac
  • 543
  • 9
  • 19