Repository navigation
Open
Description
I am trying to build aravis and python-aravis in a python3 environment and I am getting a ctypes.cast error.
I am on Ubuntu 16.04, and I installed python3.6 under conda. I was able to build aravis, and python-aravis with no errors (although I did have to monkey-patch aravis.py to import pgi instead of import gi). I then run my test script which is this:
#!/usr/bin/env python
import pgi
pgi.require_version('Aravis', '0.6')
import aravis
import time
import sys
FRAMES=4
available_cameras = aravis.get_device_ids()
if len(available_cameras) > 0:
cam = aravis.Camera(available_cameras[0])
else:
print("No camera is on. Quitting.")
sys.exit(-1)
cam.start_acquisition()
for i in range(0, FRAMES):
print("Sleeping while capturing images...")
time.sleep(1)
print("Stopping acq...")
cam.stop_acquisition()
print("Gonna show you some images here...")
for i in range(0, 2):
print("Popping a frame...")
try:
d = cam.pop_frame()
print("Frame {} is:".format(i))
print(d)
except Exception as e:
print("UH OH, there was a problem!: ", e)
raise e
for i in range(0, FRAMES):
try:
print("Saving {} of 5 frames...".format(i))
aravis.sfn(cam, app.config['IMAGES_INCOMING'])
except Exception as e:
print("UH OH, there was a problem!: ", e)
raise eWhen I run my test script I get this:
$ ./test.py
Sleeping while capturing images...
Sleeping while capturing images...
Sleeping while capturing images...
Sleeping while capturing images...
Stopping acq...
Gonna show you some images here...
Popping a frame...
UH OH, there was a problem!: argument 1: <class 'TypeError'>: wrong type
Traceback (most recent call last):
File "./test.py", line 35, in <module>
raise e
File "./test.py", line 30, in <module>
d = cam.pop_frame()
File "/home/vagrant/anaconda3/envs/py3/lib/python3.6/site-packages/aravis-0.5-py3.6.egg/aravis.py", line 153, in pop_frame
File "/home/vagrant/anaconda3/envs/py3/lib/python3.6/site-packages/aravis-0.5-py3.6.egg/aravis.py", line 169, in try_pop_frame
File "/home/vagrant/anaconda3/envs/py3/lib/python3.6/site-packages/aravis-0.5-py3.6.egg/aravis.py", line 191, in _array_from_buffer_address
File "/home/vagrant/anaconda3/envs/py3/lib/python3.6/ctypes/__init__.py", line 485, in cast
return _cast(obj, obj, typ)
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong typeMetadata
Metadata
Assignees
Labels
No labels
Activity
tobeycarman commentedon Jul 25, 2017
Partially figured this out -
pipinstalled packagepgidoes not seem to work, but if I install thegipackage using apt-get, it works (sudo apt-get install python-gi)So this dosen't really have to do with python3 at all. I suspect it is some small different in implementation between the
python-giimplementation of introspection vs thepgiimplementation of introspection.IamSierraCharlie commentedon Jul 25, 2017
For python 3, I thought you needed pip3 rather than pip
on ubuntu
sudo apt-get install python3-pip
then do
pip3 install pgi
The above works for me on Ubuntu
##############################
pip3 install pgi
Collecting pgi
Downloading pgi-0.0.11.1.tar.gz (235kB)
100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 245kB 2.4MB/s
Building wheels for collected packages: pgi
Running setup.py bdist_wheel for pgi ... done
Stored in directory: /home/s/.cache/pip/wheels/cc/9e/e2/a9c5dda8bc0bd98379827b52a97c0f593034d1094a55f689e7
Successfully built pgi
Installing collected packages: pgi
Successfully installed pgi-0.0.11.1
####################################
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
I'm no expert in python, but in my own experience I've found using pip / pip3 to be a better way to manage python packages over using apt.
Someone with more experience may suggest otherwise.
Steve
tobeycarman commentedon Jul 25, 2017
@IamSierraCharlie, I agree re:
pipvsapt-get. I always start withpip, but occasionally there is something I can't find withpipthat is available withapt-get.In my first post, I was actually trying to use the
condapackage manager (https://www.continuum.io/downloads) but I got really confused.I now have it working, and like I said, I think the problem before was that the
pgithat I installed withpipwas giving that error out ofctypes.cast(...), where as if I installgi(which I can't find in pip, but I did find withapt-get), then everything works perfectly...At this point I've reduced myself to only needing
python-virtualenv,python-gi, andpython-devfrom theapt-getrepos, and everything else I can get withpip.