Hello Richard, Finally found the issue. As per my understand The PyCObject API has been removed in Python 3.3. Instead of that we have to use PyCapsule, which is available in python 2.7 and 3.1+. I could see below line in python/guestfs-py.h file: #ifndef HAVE_PYCAPSULE_NEW return PyCObject_FromVoidPtrAndDesc ((void *) g, (char *) "guestfs_h", NULL); #else return PyCapsule_New ((void *) g, "guestfs_h", NULL); #endif But when run the same with python 3 this file #else part is not working as expected. So I have changed the above line as like below to work with python 3.5: #ifndef HAVE_PYCAPSULE_NEW return PyCapsule_New ((void *) g, "guestfs_h", NULL); #endif // I have removed that #else part and make it available if condition only. And now all issue fixed and able to import guestfs in python-3.5.1: [root@XXX tmp]$ python Python 3.5.1 (default, Jan 30 2018, 01:29:28) [GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] on linux Type "help", "copyright", "credits" or "license" for more information.
import guestfs help(guestfs) Help on module guestfs:
NAME guestfs - Python bindings for libguestfs DESCRIPTION import guestfs g = guestfs.GuestFS (python_return_dict=True) g.add_drive_opts ("guest.img", format="raw") g.launch () parts = g.list_partitions () The guestfs module provides a Python binding to the libguestfs API for examining and modifying virtual machine disk images. Amongst the things this is good for: making batch configuration changes to guests, getting disk used/free statistics (see also: virt-df), migrating between virtualization systems (see also: virt-p2v), performing partial backups, performing partial guest clones, cloning guests and changing registry/UUID/hostname info, and much else besides. Libguestfs uses Linux kernel and qemu code, and can access any type of guest filesystem that Linux and qemu can, including but not limited to: ext2/3/4, btrfs, FAT and NTFS, LVM, many different disk partition schemes, qcow, qcow2, vmdk. Libguestfs provides ways to enumerate guest storage (eg. partitions, LVs, what filesystem is in each LV, etc.). It can also run commands in the context of the guest. Also you can access filesystems over FUSE. Errors which happen while using the API are turned into Python RuntimeError exceptions. : Regards, Abinaya -----Original Message----- From: Richard W.M. Jones [mailto:rjones@redhat.com] Sent: Monday, February 5, 2018 8:11 PM To: Abinaya Sandhiya Manikandan (GIS) <abinaya.manikandan@wipro.com> Cc: libguestfs@redhat.com Subject: Re: [Libguestfs] python 3 bindings on libguestfs ** This mail has been sent from an external source ** On Mon, Feb 05, 2018 at 11:58:45AM +0000, abinaya.manikandan@wipro.com wrote:
Hi,
Please find below warning which I am facing while running "make" in source code of libguestfs-1.32.4:
********************************************************************** make[2]: Entering directory `/root/rpmbuild/SOURCES/libguestfs-1.32.4/python' CC libguestfsmod_la-guestfs-py.lo In file included from guestfs-py.c:36:0: guestfs-py.h: In function 'put_handle': guestfs-py.h:56:5: warning: implicit declaration of function 'PyCObject_FromVoidPtrAndDesc' [-Wimplicit-function-declaration] PyCObject_FromVoidPtrAndDesc ((void *) g, (char *) "guestfs_h", NULL); ^ guestfs-py.h:56:5: warning: nested extern declaration of 'PyCObject_FromVoidPtrAndDesc' [-Wnested-externs] guestfs-py.h:55:3: warning: return makes pointer from integer without a cast [enabled by default]
As I said before, and as is confirmed by the message above, there is something very confused and broken about your Python installation. There's nothing much we can do about that, you need to fix it. Rich. -- Richard Jones, Virtualization Group, Red Hat https://clicktime.symantec.com/a/1/mcqaE-KrFSqv5MeP8TAzYHLGaR1iGyvYEBQsJ1e6Ess=?d=uD6ubJEzBec6H17OGiYulGMgcQX_h36Hew0td4ye7oPtVextduwrgX-V1JWNwRQM0skodl0mF2lbpZkaQGW-r7YPpfzW9cGxAwap1qbDudaTXsZ3HMrqvBQA_Pw3AxZ5Z-5dMK9GbGS46pKDK9DKadB3zpxPLSPE70zk9qGzhd2vzljn4j6qOS4BzKxGXKaWQTrvuSL6FnPaoRdjJqQkTQVlkogdj4Ekyy9GbSs9VhxGNZvIhaHi67TluoYk1iIhkYo3XwWjfMobYAMwrF6ez_hfC6TReIRQIby6cN-5YFO6ON8gQ19JgnHsjyODqkZ3i3WBwY7UFUvGwji-EbQPBlulCHCEgFpOMpor28_h-G9ScjphZCLVrxY%3D&u=http%3A%2F%2Fpeople.redhat.com%2F~rjones Read my programming and virtualization blog: https://clicktime.symantec.com/a/1/qmLqJS97hP6khMMtbb1TX76oRwapK6QOWe4uV6HULOo=?d=uD6ubJEzBec6H17OGiYulGMgcQX_h36Hew0td4ye7oPtVextduwrgX-V1JWNwRQM0skodl0mF2lbpZkaQGW-r7YPpfzW9cGxAwap1qbDudaTXsZ3HMrqvBQA_Pw3AxZ5Z-5dMK9GbGS46pKDK9DKadB3zpxPLSPE70zk9qGzhd2vzljn4j6qOS4BzKxGXKaWQTrvuSL6FnPaoRdjJqQkTQVlkogdj4Ekyy9GbSs9VhxGNZvIhaHi67TluoYk1iIhkYo3XwWjfMobYAMwrF6ez_hfC6TReIRQIby6cN-5YFO6ON8gQ19JgnHsjyODqkZ3i3WBwY7UFUvGwji-EbQPBlulCHCEgFpOMpor28_h-G9ScjphZCLVrxY%3D&u=http%3A%2F%2Frwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. https://clicktime.symantec.com/a/1/7ip8IM8WWsnwzlDdD9Ewdn13sk0pQ-woixfvwIpWnEI=?d=uD6ubJEzBec6H17OGiYulGMgcQX_h36Hew0td4ye7oPtVextduwrgX-V1JWNwRQM0skodl0mF2lbpZkaQGW-r7YPpfzW9cGxAwap1qbDudaTXsZ3HMrqvBQA_Pw3AxZ5Z-5dMK9GbGS46pKDK9DKadB3zpxPLSPE70zk9qGzhd2vzljn4j6qOS4BzKxGXKaWQTrvuSL6FnPaoRdjJqQkTQVlkogdj4Ekyy9GbSs9VhxGNZvIhaHi67TluoYk1iIhkYo3XwWjfMobYAMwrF6ez_hfC6TReIRQIby6cN-5YFO6ON8gQ19JgnHsjyODqkZ3i3WBwY7UFUvGwji-EbQPBlulCHCEgFpOMpor28_h-G9ScjphZCLVrxY%3D&u=http%3A%2F%2Flibguestfs.org%2Fvirt-v2v ______________________________________________________________________ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com ______________________________________________________________________ The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com ______________________________________________________________________ This email has been scanned by the Symantec Email Security.cloud service. For more information please visit http://www.symanteccloud.com ______________________________________________________________________