How to execute a Python script using the Python DLL? - python

I have a Python DLL already shipped and installed on the end user (guaranteed, and with a known version number).
How can I use this DLL to execute some Python scripts without shipping the Python interpreter (again)?

You'll want to embed Python in another application, and use PyRun_AnyFile*() to run it.

Related

Pyinstaller can't find a module? (error loading Python DLL)

I compiled my program with pyinstaller, and it works fine on my computer, but whenever I ty to run it in another computer (with no python), I get the following error:
Error loading Python DLL
'C:\Users\perez\AppData\Local\Temp\_MEI28162\python310.dll'.
LoadLibrary: Cannot find specified module
What can I do? I'm not allowed to install python on the other computer
Ok, it was not working because I compiled the script with pyinstaller having python 3.10, but Windows 7's maximum python version is 3.8
I had the same problem and it was because I was using the output in build/main instead of dist/main (dist/main.exe in case you used --onefile)
Copy the folder where your Python.exe is located and run this Python.exe

How to execute python code in C++ program

I'm trying to figure out how can I execute Python code in a C++ program. Where, The C++ program will be a static Executable which will run on systems where python is NOT installed. But it can execute Python code without Python having to be installed on the System it's running on.
I looked onto embedding the python interpreter within my Program. I found this link
Embedding Python in Another Application. But the file Python.h is not found anywhere on my system (Python 3.7). I really need help on this. What can I do to achieve this?

Running or compiling a Python script on Windows

I want to modify this Python script on Windows 7.
https://github.com/Jeremy1980/LDBoxer
The original author seems to have compiled the program into a Windows executable. Is it possible to run the script without compiling it? I tried the following at the command prompt:
python LDBoxer.py
But Windows says it does not recognize 'python'. What do I need to install and what is the correct command line syntax? According to the docs, this is the correct way to run the executable:
LDBoxer_2017a.exe ldraw_library_location ldraw_model_location_for_conversion
Thanks.
You need to make sure you have python installed, then make sure you are running the correct python compiling command. Sometimes when installing python 2 you need to run the command python2 or python27.
You can install python here. It looks like they wrote it with python 2.x so I would recommend installing python version 2.7 unless you want to manually convert it to python 3.x.
You should be able to run the .exe just by double clicking, or right click then run.

environment with multiple python interpreter

On Mac, if installed multiple Python interpreter (anaconda, Python 2.7 standard, etc.), wondering when running command python, is there a way to specify if I run with anaconda or Python 2.7 or other Python interpreter?
If you only type python, it will take you to the version of python specified by this:
which python
This command will print out the location of python in your terminal.
To use a version other than the one above, be it Jython or Anaconda or whatever, you can to run it by typing out the fully qualified path.

Can the Python interpreter and Python app source code be embedded into a compiled program?

I want to put the Python interpreter and all the source files of a fairly large Python application with multiple .py files into an executable Linux file.
Thus when running the application, the Python interpreter will run the Python source code that is embedded into the executable.
Using Python 3.
Is such a thing possible?
Edit: in addition to the selected answer another option is to use Cython.
Sounds like you're looking for a packaging module, like py2exe or cx_Freeze (I prefer the latter). They bundle the interpreter and your files together so that a machine without an installation of Python can run your program.

Categories

Resources