EXIficient implementation in Python - python

I am trying to use EXI in order to encode an XML Message with Python. I've already seen that there is a Java, javascript and c/c++ implementation of EXI but I can't find a Python one. The only one i saw was the following:
https://github.com/salarshad/pyexip
The problem is that when I try to install it i get the following error:
gcc: error: exip-0.4.1/bin/lib/libexip.a: No such file or directory
error: command '/usr/bin/gcc' failed with exit code 1
Was someone able to work with this library? Is there another way to Transform XML to binary with Python?
Thank you in advance

Note: there is some confusion about the implementations (names).
https://github.com/salarshad/pyexip is a wrapper around EXIP (http://exip.sourceforge.net/), not EXIficient.
EXIficient is a Java implementation of the EXI specification and as far as I know there are ways to call Java from Python...

Related

Python importing ActiveX DLL issue

This will be my first question.
I am trying to use python to import a SDK which provides ActiveX DLL and ocx file.
I tried using
clr.FindAssembly(“dllname.dll”)
clr.AddReference(“dllname”)
to load while I have error showing:
System.IO.FileNotFoundException: Unable to find assembly 'MyDLL'
Python.Runtime.CLRModule.AddReference(String name)
Then I tried using
ctypes.WinDLL(‘dllname.DLL’)
But I cannot find any functions inside of it.
Can anyone tried to provide any ideas?
Many thanks!

Failed to build boost_python example code "fatal error LNK1181: cannot open input file 'boost_python.lib'"

I am fairly new to boost python, and I am attempting to follow this tutorial: https://www.boost.org/doc/libs/1_63_0/libs/python/doc/html/tutorial/tutorial/hello.html . Following the tutorial exactly, I receive this error upon building the project using either b2 or bjam:
" fatal error LNK1181: cannot open input file 'boost_python.lib' "
I believe I have properly configured my user-config.jam, jamfile, and jamroot files.
I also saw this thread here:
LNK1181: cannot open input file 'boost_python.lib' in windows, boost_1_68_0
but no solutions to the issue seemed to have been provided. Instead it is suggested that bjam/b2 are not needed at all, which seems to contradict the tutorial in the boost documentation.
The same user then suggested "linking" with the boost python and python libraries, which I assume means to add their directories to system environment variables. I have already done this, but I believe I could be misunderstanding what he meant.
The thread also links to this page:
https://learn.microsoft.com/en-us/visualstudio/python/working-with-c-cpp-python-in-visual-studio?view=vs-2017
detailing the creation of c++ extensions for Python, but after reading it I fail to see any mention of boost whatsoever except in passing at the very end of the article.
I have also searched the entire boost directory for a 'boost_python.lib' file and it seems that it does not exist. Any help would be greatly appreciated.
A quick Google search brought me to this answer:
You need to build the shared boost_python library using this command:
bjam toolset=msvc --prefix=..\\%BOOST_PREFIX% --with-python
--python=2.7 release link=shared --build-type=complete
address-model=64 install
You might have to adjust some options, but it should work as it worked for someone else.
-u/GeeDeexd

Error in calling a Python script from a Basic function

I am new in Python and Basic. I am trying to replicate the IMPORTHTML function from Google Sheets in LibreOffice (LO) Calc. In a nutshell, I want to create a GetHtmTable( Url, Table Index) Basic function in Calc which will call a Python script to do the heavy work.
So based on Villeroy's great example, I implemented in LO 5.1.6.2. the Basic SOUNDEX function which calls the Python script sheetFunctions.py to get familiar with the process. My environment is Linux Mint 18, I use Python 3, I imported all kind of libraries such as Uno, PIP etc.. I use PycharmProjects as a Python editor.
I see clearly under the LO Calc menu tools->macro->organize macros->python the sheetFunctions.py Python script, which indeed is in the folder /usr/lib/libreoffice/share/Scripts/python.
Whenever, I run the SOUNDEX Basic function I see the following error message:
BASIC runtime error. An exception occurred Type:
com.sun.star.script.provider.ScriptFrameworkErrorException Message:
: an
error occurred during file opening
/usr/lib/libreoffice/program/pythonscript.py:429 in function
getModuleByUrl() [lastRead = self.sfa.getDateTimeModified( url )]
/usr/lib/libreoffice/program/pythonscript.py:993 in function
getScript() [mod = self.provCtx.getModuleByUrl( fileUri )]
I tried to debug the SOUNDEX basic function and found out the blocking point is when the program runs getScript("vnd.sun.star.script:sheetFunctions.py$soundex?language=Python&location=user").
I've been trying for days now to overcome this error, unsuccessfully I must confess.
I wonder if I need to bring some extra extensions in the Basic environment or a missing add-in in the Linux/Python one?
I changed the location=user by location=document and got stuck again. I added recently libreoffice-script-provider-python thanks to the command sudo apt-get install libreoffice-script-provider-python but this did not help. I also embedded in the Calc document the Python script but same this did not solve the issue.
The location name does not match. The standard place for self-written scripts is under the user directory. This is location=user, for example ~/.config/libreoffice/4/user/Scripts/python.
Then there is location=share, which refers to the path in your question. These parameters are described under Python Script in the URI Specification.
See also my answer to this question. Be sure to try the APSO extension if you haven't yet. Especially, APSO helps when using location=document, because embedding requires several steps including editing manifest.xml.

Cstdint Missing Error When Installing Pydaedalus with PiP

I am working on an application which involves route finding (a completely different subject), but for testing I need example mazes to test on. A colleague suggested I use pydaedalus to generate large scale mazes in the format I need. I am using the following code to try and install the module:
$pip3.6 install pydaedalus
This returns the following error:
-Wno-error=format-security
In file included from daedalus/_maze.cpp:467:
In file included from daedalus/wrapper.h:8:
daedalus/src/util.h:31:10: fatal error: 'cstdint' file not found
#include <cstdint>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
I have done some research and have found nothing which addresses this. I have also done some (limited) C++ development using cstdint, which has always worked.
I came across this question, but it appears to address a separate issue.
I am developing in OSX 10.10.5
Any help that you can provide is much appreciated!
These compile errors are down to daedalus's requirement of the C++11 standard, which is sometimes a bit tricky to get working on Mac OS X. One idea might be to check to make sure your Xcode is completely up to date.
The page you linked also suggests to try linking against clang's standard library instead of the GCC standard library. I'm not sure if this will work, or if it will give you linking errors on build or when you import daedalus into python, but you could give it a shot anyway:
CFLAGS='-stdlib=libc++' pip3.6 install pydaedalus
Another idea would be to encourage pip to use the clang++ frontend, which your link also suggests might help. You should be able to set this with the environment variable CXX (or, just possibly, CC).
CXX=clang++ pip3.6 install pydaedalus
Try various combinations of those environment settings (e.g., CXX and CFLAGS), and hopefully something will work eventually.

Error: 'python35_d.dll is missing' while running C++ code with Python in MS Visual Studio 2015

I am trying to embed Python in my C++ code to use WordNet through nltk. I am new to Python and I am using MS Visual Studio 2015 to do the same but I'm facing problems to use Python on MSVS 15.
So far I've,
installed Python 3.5.1,
included this path: ...\Python\Python35-32\include, which let me include the Python.h library,
added this path: ...\Python\Python35-32\libs to access the lib files, and python35.lib as dependency in Linker\Input setting of MSVS15,
then there an error occurred, demanding python35_d.lib, so I compiled Python's source in Debug mode & copied that file to that ...\libs folder and it solved the problem.
This all happened when I was trying to run this only-
Py_Initialize();
PyRun_SimpleString("print (\"Hello World!\\n\")");
Py_Finalize();
Now I'm trying to run a Python function from a .py file. I'm trying to run this from the Python tutorials but I'm getting this error -
While debugging, I have found that when this macro gets called: Py_DECREF(), this error occurs.
Do I only need to copy python35_d.dll from PCBuild\win32 to C:\Windows\[System|System32|SysWOW64]\ to solve the problem as I don't know if it'll have any side-effects?
Although the file is already present in ...\Python\Python35-32\DLLs\.
Is there a proper setup to be done before running Python in C/C++ using MSVS, like this for Unix-like systems? (I mean by adding other dependencies or folders to the settings)
I've been reading Python documentation continuously and even other stackoverflow questions but I'm still struggling a lot (I don't know why) even to do simple things.
Can somebody guide/enlighten me for something I may be missing because I'm continuously getting errors here & there, please?
Thanks.
copy python35.dll into the folder where .sln file is present

Categories