AttributeError: module 'guidedlda' has no attribute '_guidedlda' - python

I am using the GuidedLDA library which is a modified version of LDA on my Windows 10 machine with Python 3.6 in Jupyter Notebook. The packages have the following structure:
Pacakge Folder screenshot
Since the _guidedlda.c file is written in Cython, I am getting the following error in the import stage itself.
AttributeError: module 'guidedlda' has no attribute '_guidedlda'
Would be great if anyone could help.

Found a fix (not really a fix, just a way around) myself:
Use Microsoft Visual Studio Code and not Jupyter/PyCharm or any other editors. VS Code supports C and C++ build tools well.
I would recommend creating a new Python 3.6 virtual environment in VS Code solely for using this guidedLDA library.

Related

ModuleNotFoundError: No module named 'numpy' on Fedora

I'm having this problem when i try to import numpy or any other modules of python on PyCharm or Visual Studio Code.
here's some things that i tried:
When i try to import direct via Python CLI the import works perfectly without any changes but when i use Visual Studio Code or Pycharm this problem happens even using their CLI, i tried the flatpak and distribution version of Pycharm and the problem continues.
I tried to change python interpreter of VSC using "commmand palette Python: Select interpreter" and the problem still happening
I installed Fedora workstation 37 on a VM only installing Pip, Numpy, VSC Flatpak via FlatHub and IntelliCode extension and the problem continues
Can someone help me?
EDIT: I find the problem, the reason why i was having this problem is because the VSC Flatpak isn't well integrated with the system therefore not able to acess SDKs of my host system.
To anyone having similar problem you can see how to solve here.

No module named '_swigfaiss' in Windows

I have an existing linux python project that uses faiss.
The project has the following swigfaiss wrapper as detailed here: https://github.com/facebookresearch/faiss/blob/master/INSTALL.md
And the python source code includes faiss as follows:
import faiss
When I run it in windows (in Visual Studio 2019) I get the error:
No module named '_swigfaiss'
I think I need to convert the program to run on Windows as the _swigfaiss.so is obviously built for Linux.
I have downloaded and built the Windows version of faiss using Visual Studio here: https://github.com/bitsun/faiss-windows. This produces a library file faissd.lib
How can I use this library file in my python program?
Or get the original to work on Windows?

Pyan module throwing error with Python 3.4 version

I am doing a static analysis of Python code. The Python version my system has is 3.4.3. When I run the Pyan module to draw call graph, it throws an error in the Pyan code.
pyan relies on the compiler package which has been deprecated since 2.6 and removed in Python3.
There's currently an open ticket on the GitHub project to rewrite pyan for Python 3.
If you were so inclined you could look into updating pyan to use Python3 yourself.

How can I force CMake to use the correct OpenCV version?

I'm trying to run a python script that uses a custom module written by someone else. I created that module by running CMake according to the creator's instructions. Running my python script, I get the error: ImportError: libopencv_imgproc.so.3.1: cannot open shared object file: No such file or directory. This error is caused by the module I created earlier.
There is no file of that name since I have OpenCV 3.2.0 installed, so in usr/local/lib there's libopencv_imgproc.so.3.2.0. I don't know how to fix this or where to start looking. The CMakeLists.txt of the module has a line
find_package(OpenCV 3 COMPONENTS core highgui imgproc REQUIRED).
I tried changing it to
find_package(OpenCV 3.2.0 COMPONENTS core highgui imgproc REQUIRED),
without success.
The problem was an old version of the module lurking an a different folder where the python script was actually looking. This must have been created in the past with an OpenCV 3.1 environment.

ImportError: DLL load failed: Invalid access to memory location. Using aubio in Python

For a schoolproject I need to make use of the aubio library. However, I have a problem compiling it for Windows.
I downloaded the latest source from his git (0.4.0 alpha). Then I compiled it using Cygwin, using the --with-target-platform=win32 to cross-compile it for Windows. It uses waf by the way.
This works without any errors.
Next step is copying the compiled file (libaubio.dll.a) to MinGW library folder. Then I want to compile the Python wrapper for the module, but it shows up the ld.exe cannot find -laubio error. Renaming the libaubio.dll.a to libaubio.a resolves this and compiling succeeds succesfully.
Installing it into the Python folder works perfectly too. But here starts the problem. When trying to import aubio, I get this error: ImportError: DLL load failed: Invalid access to memory location.
I have no clue on how to solve this problem. Can anybody help? Or explain the error to me?
Thanks in advance!
Xander
PS. It compiles perfectly on both OSX and Ubuntu.
Well, this may not be the right solution for you, just a hint. ImportError: DLL load failed: Invalid access to memory location. I encountered the same error when trying to make my own extension of Python programmed in C. Platform: Windows 32bits.
It was a real pain because this error appeared randomly in interactive as well as in non-interactive mode in all Python environments (Spyder, Notebook, plain console...). I compiled my code using MinGW and Python's distutils (command python setup.py install). The compilation gave no warnings or errors and produced pyd file to the correct directory. But when trying to import this module import example pro my Python code it irregularly crashed (usually only one out of five attempts to import the module succeeded).
Strange was that on another computer it worked just fine... Well, finally I found workaround - I downloaded a newer version of MinGW (before I had used the version that comes packed in Qt SDK distribution) and compiled the module again. Then it worked with no more crashes. However I did not find any systematic solution or explanation. So I might have something to do with the compiler (maybe absence of its DLLs? I do not know exactly) that was used to generate the pyd file.

Categories