Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.8.1 TypeError : vc_dispmanx_element_add.argtypes ... item 9 in _argtypes_ passes a union by value, which is unsupported. #604

Open
jmmec opened this issue Dec 27, 2019 · 11 comments

Comments

@jmmec
Copy link

@jmmec jmmec commented Dec 27, 2019

Hello,

picamera works great with Python 3.8.0, however a TypeError is immediately raised upon "import picamera" in Python 3.8.1 as shown below:

pi@pi1:~/DEV/CVDEV $ ./cvStart
Traceback (most recent call last):
  File "./jmTest.py", line 16, in <module>
    import picamera
  File "/home/pi/DEV/VENV_OPENCV_PYTHON3_8/lib/python3.8/site-packages/picamera/__init__.py", line 72, in <module>
    from picamera.exc import (
  File "/home/pi/DEV/VENV_OPENCV_PYTHON3_8/lib/python3.8/site-packages/picamera/exc.py", line 41, in <module>
    import picamera.mmal as mmal
  File "/home/pi/DEV/VENV_OPENCV_PYTHON3_8/lib/python3.8/site-packages/picamera/mmal.py", line 47, in <module>
    from .bcm_host import VCOS_UNSIGNED
  File "/home/pi/DEV/VENV_OPENCV_PYTHON3_8/lib/python3.8/site-packages/picamera/bcm_host.py", line 451, in <module>
    vc_dispmanx_element_add.argtypes = [DISPMANX_UPDATE_HANDLE_T, DISPMANX_DISPLAY_HANDLE_T, ct.c_int32, ct.POINTER(VC_RECT_T), DISPMANX_RESOURCE_HANDLE_T, ct.POINTER(VC_RECT_T), DISPMANX_PROTECTION_T, VC_DISPMANX_ALPHA_T, DISPMANX_CLAMP_T, DISPMANX_TRANSFORM_T]
TypeError: item 9 in _argtypes_ passes a union by value, which is unsupported.
@jmmec jmmec changed the title Python 3.8.1 TypeError : vc_dispmanx_element_add.argtypes = [DISPMANX_UPDATE_HANDLE_T, DISPMANX_DISPLAY_HANDLE_T, ct.c_int32, ct.POINTER(VC_RECT_T), DISPMANX_RESOURCE_HANDLE_T, ct.POINTER(VC_RECT_T), DISPMANX_PROTECTION_T, VC_DISPMANX_ALPHA_T, DISPMANX_CLAMP_T, DISPMANX_TRANSFORM_T] TypeError: item 9 in _argtypes_ passes a union by value, which is unsupported. Python 3.8.1 TypeError : vc_dispmanx_element_add.argtypes ... item 9 in _argtypes_ passes a union by value, which is unsupported. Dec 27, 2019
@DX37
Copy link

@DX37 DX37 commented Dec 30, 2019

I have this issue too. Just downgraded to 3.8.0 and it's fine.

@wingkitlee0
Copy link

@wingkitlee0 wingkitlee0 commented Dec 30, 2019

I also had this issue (self-compiled python 3.7.6). I ended up reflashing the OS raspbian to the newest version. It works fine now with python 3.7.4 . It seems to be a library issue than a python one..

@hsiejkowski
Copy link

@hsiejkowski hsiejkowski commented Dec 30, 2019

@wingkitlee0 I confirm your suspicion. I tested it with Python 3.8.1 and 3.7.6 with the same error. In my case, the error started to happen after a system upgrade.

@laudge
Copy link

@laudge laudge commented Dec 30, 2019

same problem for me with python 3.8.1 . bcm_host.py seams to be the cause. But I do not know how to solve it. I will revert to previous python version.

@riedwaanb
Copy link

@riedwaanb riedwaanb commented Dec 31, 2019

Also confirming this issue with self compiled 3.8.1.

@moaxey
Copy link

@moaxey moaxey commented Jan 11, 2020

I experienced this error in python 3.8.0 and 3.8.1 installed with pyenv and picamera installed with pip or pipenv..
After installing python 3.8.0 from source following this method (but install not altinstall), and no pyenv lines in my .bashrc.
Then I could pip3 install picamera and import it without the error mentioned above.

@Maigre
Copy link

@Maigre Maigre commented Jan 16, 2020

Hi,
using git version, i still have the same error with Python 3.8.1:

File "/usr/lib/python3.8/site-packages/picamera-1.13-py3.8.egg/picamera/bcm_host.py", line 451
TypeError: item 9 in argtypes passes a union by value, which is unsupported.

@BlackLight
Copy link

@BlackLight BlackLight commented Jan 21, 2020

This has been a long-standing issue in the underlying interpreter. Basically, the interpreter's support for ctype.Union passed by value has always been quite limited, as it's hard for the interpreter to get the right memory size (although that's also arguable: the memory size of a union in C always equals the size of its largest member), and it's silently been dropped in Python 3.8.1.

I was investigating how to replace DISPMANX_CLAMP_KEYS_T with a Structure or an array, but I've eventually found out that the incriminated commit has luckily been reverted after it broke quite a lot of things. At this point the best solution is to either downgrade to 3.8.0 or wait for 3.8.2.

--EDIT--

The incriminated commit has also been included in the 3.7 branch as of 3.7.6. It means that things are expected to break also on that version, as reported by @wingkitlee0. The fix however has also been backported to the 3.7 branch so it's expected to be fixed as of 3.7.7 (or builds of the current branch HEAD).

--EDIT 2--

A dirty workaround to get things working on Python 3.8.1 is to treat DISPMANX_CLAMP_KEYS_T as a ct.Structure instead of ct.Union. Since it's the only reference I've found in the code where a ct.Union is passed by value, it should be the only required change. It works for me, but I'm not sure however if this may break other use cases than mine - especially some that require YUV<->RGB color conversion.

@sgnyjohn
Copy link

@sgnyjohn sgnyjohn commented Mar 2, 2020

nunca trabalhei com linguagem tão instável, não é confiável.

@nickmmain
Copy link

@nickmmain nickmmain commented Mar 24, 2020

Can confirm that going from 3.6.7 to 3.7.7 solved this issue for me.

@hsiejkowski
Copy link

@hsiejkowski hsiejkowski commented Mar 26, 2020

With python 3.8.2 it works too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.