importing pywiiuse to test out - python

This is probably a simple problem. But I downloaded the pywiiuse library from here and I also downloaded the examples. However when I try to run one of the examples I end up with import issues. I'm not certain I have everything configured properly to run. One error I receive when trying to run example.py:
Press 1&2
Traceback (most recent call last):
File "example.py", line 73, in <module>
wiimotes = wiiuse.init(nmotes)
File "/home/thed0ctor/Descargas/wiiuse-0.12/wiiuse/__init__.py", line 309, in init
dll = ctypes.cdll.LoadLibrary('libwiiuse.so')
File "/usr/lib/python2.7/ctypes/__init__.py", line 431, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libwiiuse.so: cannot open shared object file: No such file or directory
I'm really just starting out with this library and don't really see any documentation on how to configure pywiiuse so any help is much appreciated.

The pywiiuse library is a Python wrapper for the wiiuse C library.
Before you can use the wrapper you will first need to install the library it wraps, choose the newest version from this download page and download the appropriate installation package for you system (probably the .tar.gz since you appear to be on Linux).

add the link of libwiiuse.so to /usr/local/lib.
I also ran into this situation, I konw why it happies, but I don't konw the deep reason.

Related

Is it possible to use Tabula-Py on Portable IDE

I am new to python and am working on setting up some automation for my job in python and part of that is pulling data from tables in pdf files. Short version is that no matter how I try and what I have looked up I cannot get Tabula-Py to look at the path to java on my portable drive.
I am using a portable IDE set-up since I do not have admin privilege's on my work computer.
Tabula-Py throws the usual cannot find Java make sure it is in your PATH error message. I am using Python Portable and jPortable installed to a common directory with Spyder portable as the IDE. I have run pip install and uninstall on both Tabula and Tabula-Py multiple times. I have also run import sys for sys.path.append to add the filepath to my Java bin.
Code:
import pandas as pd
import numpy
import tabula
import sys
sys.path.append('E:\CommonFiles\Java\bin')
df = tabula.read_pdf('E:\CommonFiles\Python-Portable-3.9.6\Scripts\Sample.pdf', pages='all')
Error Message:
runfile('E:/CommonFiles/Python-Portable-3.9.6/Scripts/untitled01.py', wdir='E:/CommonFiles/Python-Portable-3.9.6/Scripts')
Traceback (most recent call last):
File "E:\CommonFiles\Python-Portable-3.9.6\apps\lib\site-packages\tabula\io.py", line 80, in _run
result = subprocess.run(
File "E:\CommonFiles\Python-Portable-3.9.6\apps\lib\subprocess.py", line 505, in run
with Popen(*popenargs, **kwargs) as process:
File "E:\CommonFiles\Python-Portable-3.9.6\apps\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in __init__
super(SubprocessPopen, self).__init__(*args, **kwargs)
File "E:\CommonFiles\Python-Portable-3.9.6\apps\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "E:\CommonFiles\Python-Portable-3.9.6\apps\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\CommonFiles\Python-Portable-3.9.6\Scripts\untitled01.py", line 15, in <module>
df = tabula.read_pdf('E:\CommonFiles\Python-Portable-3.9.6\Scripts\Sample.pdf', pages='all')
File "E:\CommonFiles\Python-Portable-3.9.6\apps\lib\site-packages\tabula\io.py", line 322, in read_pdf
output = _run(java_options, kwargs, path, encoding)
File "E:\CommonFiles\Python-Portable-3.9.6\apps\lib\site-packages\tabula\io.py", line 91, in _run
raise JavaNotFoundError(JAVA_NOT_FOUND_ERROR)
JavaNotFoundError: `java` command is not found from this Python process.Please ensure Java is installed and PATH is set for `java`
I have also attempted to use camelot with a similar frustration over the ghostscript.dll.
Finally I looked into pdfplumber but had even less luck there getting it to find the tables let alone do anything with them.
I am sure this is doable but my google-fu is failing me currently and have spent the better part of 3 days looking into this with no solution I could find through Google, StackOverflow, Reddit, etc.
I had the same issue, and the solution I found is by using portable Java and registering it in the user environment path.
This explains how to install java from the EXE installer https://stackoverflow.com/a/6571736/11322275
Then, register where you saved the java folder to the user environment path as explained here https://stackoverflow.com/a/67844469/11322275
Make sure you can call java -version on your command prompt once you've done the above

PyDub OSError: [WinError 6] The handle is invalid

I'm having a similar issue on Python 3.8.7, and I can't find the solution.
In my project, I'm using pydub.AudioSegment to get audio from a file and then exporting that audio in a different format. My code works perfectly when I'm running the python file directly. However, when I convert it to an executable with pyinstaller, run the program and get to the point of importing the audio with pydub, it gives me the following error:
Traceback (most recent call last):
File "main.py", line 269, in <module>
File "main.py", line 213, in convertfile
File "main.py", line 133, in cloud_upload
File "pydub\audio_segment.py", line 728, in from_file
File "pydub\utils.py", line 274, in mediainfo_json
File "subprocess.py", line 804, in __init__
File "subprocess.py", line 1142, in _get_handles
OSError: [WinError 6] The handle is invalid
pydub call in my program looks like this:
sound = AudioSegment.from_file(filepath)
sound.export(new_filepath, format="ogg",codec='libopus')
I've tried to add stdin=subprocess.DEVNULL and stdin=subprocess.PIPE in utils.py on line 274, but that didn't work either. Maybe I added them incorrectly, though, so suggestions like that are also highly appreciated.
I've managed to solve the problem only by removing --onefile option from pyinstaller and dropping ffmpeg.exe and ffprobe.exe into the resulted folder with the main.exe file.
That's not a good solution to the problem as I'd still prefer to use --onefile; but it works.
I'm still open to suggestions on how to make it work with --onefile or just generally why this is hapenning.
Chances are is that PyInstaller cannot recognize the imported plugin. Although if you are trying to make a app, I suggest using a shortcut instead, it is better due to the fact that you can customize the icon for the shortcut. It is what many apps mainly use.

PyInstaller "You may load I/O plugins with the `skimage.io.use_plugin`"

useing Pyinstaller packages a python script
Pyinstaller version 3.2
OS:Ubuntu
Traceback (most recent call last):
File "<string>", line 57, in <module>
File "<string>", line 29, in feature_extract
File "caffe/io.py", line 295, in load_image
File "skimage/io/_io.py", line 100, in imread
File "skimage/io/manage_plugins.py", line 194, in call_plugin
RuntimeError: No suitable plugin registered for imread.
You may load I/O plugins with the `skimage.io.use_plugin` command. A list of all available plugins can be found using `skimage.io.plugins()`.
file_test returned -1
I have been getting above error. Could some one please tell me how would i fix it?
The problem seems to be related to this github issue, essentially the skimage.io._plugins submodule is making life hard for Pyinstaller.
To make sure everything you need is packaged you should have a hook file that contains
from PyInstaller.utils.hooks import collect_data_files, collect_submodules
datas = collect_data_files("skimage.io._plugins")
hiddenimports = collect_submodules('skimage.io._plugins')
(or if you already have a hook file with these, extend the current datas and hiddenimports).

Loading DLL's in Python

I'm following the guide found here:
http://www.dalkescientific.com/writings/NBN/c_extensions.html
for creating C extensions to python. But when I try to run any python program after building that module, such as the first one listed or mandelbrot.py (listed towards the end of the page). I get the error on the line libc = ctypes.CDLL("libc.dylib", ctypes.RTLD_GLOBAL)
The error is:
Traceback (most recent call last):
File "cos.py", line 5, in < module >
libc = ctypes.CDLL("libc.dylib", ctypes.RTLD_GLOBAL)
File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libc.dylib: cannot open shared object file: No such file or directory
I'm using Linux so I'm not sure if that is the problem. And if it is, how would I accomplish this on Linux? I know dll is how Windows refers to shared objects. But does the syntax change? I can't seem to find an answer anywhere.
On GNU/Linux the cos() function is located in a library called libm.so. So you need to replace "libc.dylib" with "libm.so".

Mercurial CGI (hgweb.cgi) fails

I have Mercurial 1.8.1, Python 2.6.6 installed on Win 2k8 R2 running on a vm. I have tried installing from msi, source and using tortisehg. Command-line Hg works fine but I get the same error when running the hgweb.cgi:
Traceback (most recent call last):
File ".\hgweb.cgi", line 17, in
application = hgweb(config)
File "mercurial\hgweb\__init__.pyc", line 26, in hgweb
File "mercurial\hgweb\hgwebdir_mod.pyc", line 61, in __init__
File "mercurial\hgweb\hgwebdir_mod.pyc", line 70, in refresh
File "mercurial\ui.pyc", line 35, in __init__
File "mercurial\demandimport.pyc", line 75, in __getattribute__
File "mercurial\demandimport.pyc", line 47, in _load
File "mercurial\util.pyc", line 576, in
File "mercurial\demandimport.pyc", line 85, in _demandimport
File "mercurial\windows.pyc", line 21, in
File "mercurial\demandimport.pyc", line 75, in __getattribute__
File "mercurial\demandimport.pyc", line 47, in _load
File "mercurial\osutil.pyc", line 12, in
File "mercurial\osutil.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.
The other answers I have found on SO and elsewhere pointed me to try installing from source, dropping the pure osutil into the install, or installing an older version. I have tried them all.
This is especially frustrating because I have other, similar non-vm machines running fine but have been unable to find the disconnect.
Ideas?
I had the same error using following system configuration
Python-2.6.6 installed as msi
mercurial-1.8.2-x86 installed as msi
IIS7
I solved this problem simply:
Python has been installed early
Uninstall Mercurial msi package
Download and install "Mercurial-1.8.2 (32-bit py2.6)" installer from mercurial website which is marked as "This is recommended for hgweb setups".
copyed content of C:\Python26\Lib\site-packages\mercurial\ to the directory used in IIS7 website setup.
Till now all is working. Hope this will help.
Whenever I have less than descriptive error messages that tell me something is going on at the system level but not what, I use Sysinternals' Procmon to tell me what's going with the registry and filesystem. It's verbose, and getting the filter to show just the process of interest takes some learning, but you can export the results to Excel and skim them for suspicious-looking results. Pay particular attention to failures, of course.
Give it a try and see what DLL is being searched for.

Categories

Resources