Python missing DLL from installed module - python

I got a project which consists of Python and C++. I don't understand all of it but in order to compile and run everything I run an included BAT file. I have already installed the dependencies needed. Now when I run the script, I get this:
MainProcess - [INFO] os_utils: Disabling idle sleep not supported on this OS version.
world - [ERROR] launchables.world: Process Capture crashed with trace:
Traceback (most recent call last):
File "C:\work\pupil\pupil_src\launchables\world.py", line 118, in world
from plugin_manager import Plugin_Manager
File "C:\work\pupil\pupil_src\shared_modules\plugin_manager.py", line 15, in <module>
from video_capture import Base_Manager, Base_Source
File "C:\work\pupil\pupil_src\shared_modules\video_capture\__init__.py", line 36, in <module>
from .file_backend import FileCaptureError, FileSeekError
File "C:\work\pupil\pupil_src\shared_modules\video_capture\file_backend.py", line 13, in <module>
import av
File "C:\Users\XXX\AppData\Local\Programs\Python\Python36\lib\site-packages\av\__init__.py", line 9, in <module>
from av._core import time_base, pyav_version as __version__
ImportError: DLL load failed: The specified module could not be found.
It couldn't find pyav? But if I run:
C:\Users\XXX\Downloads>pip install av-0.3.1-cp36-cp36m-win_amd64.whl
Requirement already satisfied: av==0.3.1 from file:///C:/Users/XXX/Downloads/av-0.3.1-cp36-cp36m-win_amd64.whl in c:\users\anton\appdata\local\programs\python\python36\lib\site-packages
I already have it installed. What am doing wrong here?
If I open ...site-packages\av__init__.py" I can see this:
from av._core import time_base, pyav_version as __version__
is it something here?

I suspect that the module has successfully installed, but is dynamically linked against FFMPEG. You can obtain built distributions of FFMPEG from their website (https://www.ffmpeg.org/download.html). They provide both statically linked and dynamically linked builds, though it is going to be the dynamically linked one that is providing the dll's you need. Looking at my own copy of PyAV, it seems that the current release version (3.4.2) is the one that it is linked against.
When you download it, it will have a name like ffmpeg-date-build-win64-shared. In the bin directory, you will find all the relevant DLLs. You can either add this directory to the PATH, or more easily, copy the DLLs to your python location.

Related

ModuleNotFoundError: No module named 'utils.cython_bbox'

I'm a student and a complete newbie, so please forgive me if this is a basic question. I have followed the instructions to run PCL model (https://github.com/ppengtang/pcl.pytorch) on the voc2007 data by following the instructions on the github page.
I'm using Windows 10 64 bit, Python 3.10.5, and as far as I can tell I've installed all dependencies including Visual Studio Code C++ libraries, SDK etc., although I had a lot of trouble trying to install cython_bbox.
When I run in CMD:
python tools/test_net.py --cfg configs/baselines/vgg16_voc2007.yaml \ --load_ckpt Outputs/vgg16_voc2007/$MODEL_PATH \ --dataset voc2007trainval
I get the following:
C:\Users####\py_virtual_env\lib\site-packages\torchvision\models\detection\anchor_utils.py:63: UserWarning: Failed to initialize NumPy: module compiled against API version 0x10 but this version of numpy is 0xf (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:68.)
device: torch.device = torch.device("cpu"),
Traceback (most recent call last):
File "C:\Users####\pcl.pytorch\tools\test_net.py", line 14, in
from core.test_engine import run_inference
File "C:\Users####\pcl.pytorch\lib\core\test_engine.py", line 36, in
from core.test import im_detect_all
File "C:\Users####\pcl.pytorch\lib\core\test.py", line 43, in
import utils.boxes as box_utils
File "C:\Users####\pcl.pytorch\lib\utils\boxes.py", line 54, in
import utils.cython_bbox as cython_bbox
ModuleNotFoundError: No module named 'utils.cython_bbox'
In the lib\utils folder, there are two files: cython_bbox.c and cython_bbox.pyx. This appears to be the root of the issue but I have no idea what exactly the issue is or how to fix it.
For information, I also have:
Requirement already satisfied: cython_bbox in c:\users####\py_virtual_env\lib\site-packages (0.1.3)
I've searched online for a solution but cannot find one.
I'd appreciate any help.

Error installing pyflycapture2 on Windows

I am attempting to install this https://github.com/jordens/pyflycapture2 python binding on my Windows machine. The readme only has instructions on how to do it for Linux systems, but I imagine the library should still work.
I am able to run "python setup.py install" and it seems to successfully complete, but when I try to run "python test_flycapture2.py" I get this error:
C:\Users\clinic\Desktop\pyflycapture2>python test_flycapture2.py Traceback (most recent call last):
File "test_flycapture2.py", line 20, in <module>
import flycapture2 as fc2
File "build\bdist.win-amd64\egg\flycapture2.py", line 7, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
This seems to imply that flycapture2 wasn't installed correctly. When I instead just open a python session and do "import flycapture2" I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 7, in <module>
File "build\bdist.win-amd64\egg\flycapture2.py", line 6, in __bootstrap__
ImportError: DLL load failed: The specified module could not be found.
Have I done something wrong with the installation process or does pyflycapture2 just not work with Windows?
A dumb solution that's worth a try. There are chances that the DLL are searched directly from where you're starting the python script. So if you have the dll somewhere on your computer, copy it along where you have your test_flycapture2.py.
But given the fact that the setup.py file has a whole bunch of absolute paths in there, I would not place my hopes too high. You can also try to install FlyCapture 2 at the exact same path, run python setup.py bdist_wheel (you will need to install wheel first with pip) in the pyflycapture2 folder, and see if that succeeds.
If it does, try installing the generated wheel (that will be in dist/ subfolder) by doing pip install dist/pyfly....wheel and test again.
Hope this helps
I'm answering this mostly because I found another post where the same question had been posted but the original problem was never answered.
How do I run an installed Python module on Windows?
In the comments, the original poster says that it suddenly started working. I found that the solution was simply to restart my computer. I have now attempted this on two computers and this worked for both of them.

import magic throws exception

So I used pip to download filemagic:
E:\cuckoo-current\cuckoo>c:\Python27\Scripts\pip.exe install filemagic
Downloading/unpacking filemagic
Downloading filemagic-1.6.tar.gz
Running setup.py (path:c:\users\vaclav~1.vas\appdata\local\temp\pip_build_vaclav.vasenka\filemagic\setup.py) egg_info for package filemagic
Installing collected packages: filemagic
Running setup.py install for filemagic
Successfully installed filemagic
Cleaning up...
I've created test.py with content:
import magic
print "test"
And when I run the file import throws exception:
Traceback (most recent call last):
File "E:\sand\test.py", line 2, in <module>
import magic
File "C:\Python27\lib\site-packages\magic\__init__.py", line 18, in <module>
from magic.identify import Magic, MagicError
File "C:\Python27\lib\site-packages\magic\identify.py", line 16, in <module>
from magic import api
File "C:\Python27\lib\site-packages\magic\api.py", line 22, in <module>
raise ImportError('Unable to find magic library')
ImportError: Unable to find magic library
Is the filemagic corrupted ? Is this module even working ?
From the PYPI Description (emphasis mine)
A Python API for libmagic, the library behind the Unix file command
and
libmagic is the library that commonly supports the file command on
Unix system, other than Max OSX which has its own implementation. The
library handles the loading of database files that describe the magic
numbers used to identify various file types, as well as the associated
mime types. The library also handles character set detections.
You cannot use this on Windows, as you are attempting.
You can attempt to use the mimetypes module in the standard library (mimetypes.guess_type would be what to look at).
I faced the same problem with docker containers with Alpine Linux image:
It seems like in Alpine Linux the library search doesn't work, hence it fails to find 'libmagic.so.1' which is required for the working of magic library( dependency filemagic and libmagic).
Workaround:
Use Python slim instead of Alpine Linux
mime, mimetypes are the other python libraries which can be used (the only downside to these two libraries is, that they find the mime type based on file extension and not file headers.

RuntimeError: could not find any library for SDL2_ttf

I have a problem with pysdl2. I'm trying to launch examples from site-packages\sdl2\examples and see this error:
c:\Python33\Lib\site-packages\sdl2\examples>python draw.py
Traceback (most recent call last):
File "draw.py", line 10, in <module>
import sdl2.ext as sdl2ext
File "C:\Python33\lib\site-packages\sdl2\ext\__init__.py", line 14, in <module>
from .common import *
File "C:\Python33\lib\site-packages\sdl2\ext\common.py", line 8, in <module>
from .. import sdlttf
File "C:\Python33\lib\site-packages\sdl2\sdlttf.py", line 40, in <module>
os.getenv("PYSDL2_DLL_PATH"))
File "C:\Python33\lib\site-packages\sdl2\dll.py", line 51, in __init__
raise RuntimeError("could not find any library for %s" % libinfo)
RuntimeError: could not find any library for SDL2_ttf
But files which don't use sdl2_ttf (such as sdl2hello.py) work correctly and without errors. I have no idea how to solve it.
Additional info: WinXP SP3 32bit
This error seems to be the result of the script not finding the SDL2_ttf package.
Following the instructions of the PySDL2 manual, you must have set a PYSDL2_DLL_PATH like so:
# Win32 platforms
set PYSDL2_DLL_PATH=C:\path\to\fancy_project\third_party
# Unix/Posix-alike environments - bourne shells
export PYSDL2_DLL_PATH=/path/to/fancy_project/third_party
# Unix/Posix-alike environments - C shells
setenv PYSDL2_DLL_PATH /path/to/fancy_project/third_party
so you just have to get the SDL2_ttf package here: http://www.libsdl.org/projects/SDL_ttf/ and download the runtime library corresponding to your system (http://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.12-win32-x86.zip) and add it in the same folder where SDL2.dll is. Check out at C:\your-python-directory\DLLs
It's the same with SDL_image, SDL_mixer, SDL_net and SDL_gfx (on another website though for this last one).
Hope this helps !
Got the same issue
brew install sdl2
Solved my problem on OSX

Shared library _sqlite3.so not found when importing sqlite3 on Python 2.6.6

Okay i've been battling for this for 2 days, that usually means its something too simple to realize.
I have an embedded linux system which I cross compile on my ubuntu. When compiling python, sqlite3 is not on the list of modules that have not been able to be compiled.
But, the _sqlite3.so library is not in the same location as for example json.so and ctypes.so array.so...
in Python-2.6.6/build/lib.linux868-2.6/
The actual module with the init-functions etc is in the right place at :
in Python-2.6.6/modules and it can also be found on the target system.
Since the so-file was missing, i tried compiling it myself as a shared library using my arm-compiler. This did not work either.
Without manually compiled so-file:
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "rootfs/python/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
File "rootfs/python/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
ImportError: /python/lib/python2.6/lib-dynload/_sqlite3.so: cannot open shared object file: No such file or directory
With the compiled shared library found at lib-dynloads:
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "rootfs/python/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
File "rootfs/python/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
ImportError: dynamic module does not define init function (init_sqlite3)
Edit:
I was wondering if i had compiled the right library for sqlite3. As far as i now understand the _sqlite3.so is something the python builder makes and libsqlite3.so is the library it needs to build it? And libsqlite3.so is build from Sqlite3-source code. Am i mistaken here?
Anyone with more embedded Linux or Python experience have an idea what I am doing wrong here?
Try to compile and install sqlite3 first on your system, and compiler python later. Or just
easy_install pysqlite
Ok, figured this out. Somehow I did not manually compile the SO-file correctly. Got this to work like so:
First from setup.py , I added verbose debugging enabled for sqlite3 module. This added a printout that solved the problem:
skipping incompatible /usr/lib/libsqlite3.so
cannot find -sqlite3
That made me realize that the setup.py had chosen the first path where it found any module named sqlite3, ignoring it's architecture alltogether. Removing other search paths from the setup.py, but the one i had the ARM compiled library in, made it work. The _sqlite3.so was compiled nicely with all the other modules.

Categories

Resources