-1

I want to develop a Unity application that communicates with a Python script via socket to exchange information. However, I don’t want to run Unity and the Python script separately. Is there a way to package everything into a single executable, ensuring that the Python script runs alongside the Unity application? How can I achieve this?

I was thinking of doing something via the terminal, but I’m not sure how to proceed. I’d like some ideas on possible ways to make this work in my case.

9
  • run python inside unity? Commented Mar 23 at 18:48
  • Or as a background Process ? Commented Mar 23 at 18:49
  • stackoverflow.com/questions/71179346/… Commented Mar 23 at 18:51
  • @BugFinder Yes, the idea is to run a neural network in Python, like MediaPipe, to process webcam data and send the results to Unity via socket. For example, Python could track the user's hand and send the data in real-time to control a virtual hand in Unity. Commented Mar 23 at 18:54
  • @derHugo Yes, Python would run in the background using Process, but I want to package everything into a single executable so the user doesn’t have to start Unity and Python separately. I want the program to launch everything together automatically. Commented Mar 23 at 18:54

1 Answer 1

0

If this is for a windows build I think there are mainly three options

Have your users install python as dependency

Probably not really desirable as it requires additional steps by your users and might of course introduce hickups

Portable Python

You could give it a shot and simply pack WinPython (a fully portable python) into your project and then as mentioned run a Process using that library to then run your python server script.

This depends a bit on your python requirements. There is a minimal version and also a very huge "complete" version - but nothing custom inbetween.

Compile to Exe

Similar to above but alternatively you could also use a tool like e.g. Py2Exe and beforehand already compile your python server script into an .exe file. You can then again simply pack it into your project and run via Process from within your c# code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.