Questions tagged [python-embedding]

Questions regarding embedding Python interpreter in other applications, such that it may serve as a scripting language.

When embedding Python, the interface code does:

  • Convert data values from C to Python,

  • Perform a function call to a Python interface routine using the converted values, and

  • Convert the data values from the call from Python to C.

Reference

309 questions
0
votes
1 answer

Embedded Python install manually package without pip

I download and unzip python-3.9.6-embed-amd64.zip file from python.org . Then, I unzipped python39.zip and I found site-packages folder in there.I added manually pandas package from pypi. Lastly, I tried this command: python.exe setup.py install .…
0
votes
1 answer

Inspecting memory leaks in C++ with embedded Python

I am writing a C++ code that embeds a Python module. I'm importing the module just once at the beginning; then, the C++ code repeatedly calls a single function from it. To do so, I've used the following syntax (here reporting a minimum working…
0
votes
1 answer

Import Python module from path in embedded Python

I'm using embedded Python in C++. I can import a module like so, given my_module.py is a file: PyObject* pName PyUnicode_DecodeFSDefault("my_module"); PyObject* pModule = PyImport_Import(pName); This works nicely for the most part, except that I…
Lara
  • 2,594
  • 4
  • 24
  • 36
0
votes
1 answer

Deploying a pre-built embedded Python environment on Windows

I'm looking at setting up a completely self-contained Python environment which will get carried (or downloaded) by my .NET app installer. This Python environment will be used via pythonnet to execute Python code from a .NET app context. The…
Vlad
  • 1,889
  • 17
  • 33
0
votes
1 answer

Why are there rows with all values ​0 in the embedding matrix?

I created the word embedding vector for sentiment analysis. But I'm not sure about the code I wrote. If you see my mistakes while creating Word2vec or embedding matrix, please let me know. EMBEDDING_DIM=100 review_lines = [sub.split() for sub in…
Seda Yılmaz
  • 31
  • 1
  • 8
0
votes
0 answers

LSTM parameters

Hi every one i am using pytorch to text classification, for first time i used the number of 44 data for train and the number of 22 for test data, my vocab-size is 531, and my lstm parameters are shown below, but at last in embedding i get this…
0
votes
1 answer

Global word embedding for local word embeddings

Imagine, based on some criteria, we have three vectors (vec1, vec2, vec3) for the word king, and we call these three vectors as local vectors for the king. Which way is sufficient to generate a global (single, or unique) vector for the word king…
0
votes
0 answers

What is the correct way to import a python module wrapped with swig in c++

Creating a python module with swig is the easy part. But what if this module has to interact with my C++ application that imports it from its embedded python instance? For example @Flexo has made a pretty good example on how to expose the python…
0
votes
1 answer

How embedding_bag exactly works in PyTorch

in PyTorch, torch.nn.functional.embedding_bag seems to be the main function responsible for doing the real job of embedding lookup. On PyTorch's documentation, it has been mentioned that embedding_bag does its job > without instantiating the…
0
votes
0 answers

Passing vector as argument to python function using boost python

I followed https://riptutorial.com/boost/example/25280/wrapping-std--vector-in-boost-python but how to include vector_indexing_suite for passing vector as argument? I am getting the error: No Python class registered for C++ class std::vector > when…
0
votes
1 answer

How is it possible to access a Python module in C++?

I'm trying to import a module in C++; the module resides in a package and should be accessed like: from x.y import class1,func1, const1, etc I'm on Python 3.6 and for this version what I have found so far is to use PyRun_SimpleString to do the…
Hossein
  • 24,202
  • 35
  • 119
  • 224
0
votes
0 answers

Python embedding in C# (cTrader/cAlgo bot PyTorch call bug)

I am trying to run some Python code within my C# script, which is something called a "cAlgo bot", using an API which interacts with a program called "cTrader". However, I don't think this part is technically relevant to the problem I am having. I am…
Tom
  • 89
  • 8
0
votes
0 answers

Uploading python development enviroments library to Hi3519 SoC (System on Chip)

I have a License plate recognition system which is written in python, and it uses openCV and OpenALPR as the main libraries along with other additional libraries. In my possession I have a Hi3519 SOC (system on chip) and I would like to upload the…
vijay
  • 1
  • 1
0
votes
1 answer

Stuck at PyObject_GetAttrString() : How to get my Python function script from my C++ code

My problem is that I cannot get a function from my Python script on my C++ script. I use Python/C API and my IDE is VScode. When i run the code, it stop at the specific line calling PyObject_GetAttrString() This line into the task.json of VScode is…
0
votes
1 answer

Embedding Python in C: Undefined reference (but works in Go)

I'm trying to embed Python 3.7 in a C application in Windows 10. #define PY_SSIZE_T_CLEAN #include int main () { Py_Initialize(); PyRun_SimpleString("print('OK')"); } I use the following command to compile:…
user42723
  • 467
  • 3
  • 8