0

I am currently running some Python scripts in a Visual Studio C++ application using the Python/C api. The application is using Python that is installed on my system. However, I'd like to distribute the application without requiring the user to install python manually. I was told to use the embeddable Python version. I found and downloaded the Python 3.8.0 Windows x86-64 embeddable zip file from here. I extracted the contents and now have no idea how to continue. I clearly see the python38.dll (I am assuming this needs to the new dll that the application depends on), but how do I pack it into the output .exe file?

I appreciate the help in advance, and let me know if there is any information I am missing!

2
  • Please read the tag descriptor before using a tag. Commented Oct 7, 2022 at 18:48
  • I am afraid python need to be installed or or some other options from the similar thread: some parts of the application occasionally call the Python interpreter to run some Python code. Commented Oct 11, 2022 at 7:11

1 Answer 1

0

In order to use the Python-C API you need to first import it in your code. This is done by adding #include “Python.h” to your code. However, for this to work you first need to add the python include files to your compiler search directory. In Visual Studio 2019, this is done by adding the include directory from your python install to Properties > C/C++ > General > Additional Include Directories.

Next, you need to add the python library to your linker. Add the libs directory from your python install to Properties > Linker > General > Additional Library Directories.

Lastly, you need to specify the library name to the linker. This is done in Visual Studio by adding the name of the python library (depends on your version of python and is found in {python install directory} \libs) to Properties > Linker > Input > Additional Dependencies.

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

3 Comments

Yep I got all this. But if I want the application distributed, wouldn't the user have to manually install python on their system? This is what I want to avoid.
@levente.nas Need to distribute python DLL along with exe to users.
@MinxinYu-MSFT How can I accomplish this?

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.