virtualbox-python icon indicating copy to clipboard operation
virtualbox-python copied to clipboard

Exception: Cannot find VBoxPython module (tried: VBoxPython3_6, VBoxPython3, VBoxPython)

Open printdhruv opened this issue 5 years ago • 29 comments

ENVIRONMENT
  • Operating System: macOS High Sierra 10.13.6
  • Python version: Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin- VirtualBox version:
  • VirtualBox SDK version: /Applications/VirtualBox.app/Contents/MacOS/sdk/- Location where VirtualBox SDK is installed:/Applications/VirtualBox.app/Contents/MacOS/sdk/installer
  • pyvbox version:1.3.2
  • [Not Sure] Happens in latest master branch?
SUMMARY

It doesn't work even after setting up paths.

STEPS TO REPRODUCE
import virtualbox
vbox = virtualbox.VirtualBox()
EXPECTED RESULTS
ACTUAL RESULTS
m=VBoxPython3_6 x=No module named 'VBoxPython3_6'
m=VBoxPython3 x=No module named 'VBoxPython3'
m=VBoxPython x=No module named 'VBoxPython'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/anaconda3/lib/python3.6/site-packages/virtualbox/library_ext/vbox.py", line 22, in __init__
    manager = virtualbox.Manager()
  File "/anaconda3/lib/python3.6/site-packages/virtualbox/__init__.py", line 143, in __init__
    self.manager = vboxapi.VirtualBoxManager(mtype, mparams)
  File "/anaconda3/lib/python3.6/site-packages/vboxapi/__init__.py", line 989, in __init__
    self.platform = PlatformXPCOM(dPlatformParams)
  File "/anaconda3/lib/python3.6/site-packages/vboxapi/__init__.py", line 750, in __init__
    import xpcom.vboxxpcom
  File "/Applications/VirtualBox.app/Contents/MacOS/sdk/bindings/xpcom/python/xpcom/vboxxpcom.py", line 78, in <module>
    raise Exception('Cannot find VBoxPython module (tried: %s)' % (', '.join(_asVBoxPythons),))
Exception: Cannot find VBoxPython module (tried: VBoxPython3_6, VBoxPython3, VBoxPython)

printdhruv avatar Sep 13 '18 22:09 printdhruv

This might be a good place to start as this issue seems related: https://github.com/SethMichaelLarson/virtualbox-python/issues/102

sethmlarson avatar Sep 14 '18 13:09 sethmlarson

So, what's the resolution there? You are working on that ! I tired that dirty hack but still doesn't help. Would you like to suggest some other hack/package/etc to solve this issue?

printdhruv avatar Sep 14 '18 18:09 printdhruv

Could you provide the output of: nm -D [Wherever VirtualBox.so files are installed] | grep PyInit to help me understand why the dynamic library isn't loading? I don't own a macOS system to try this on, unfortunately.

sethmlarson avatar Sep 14 '18 18:09 sethmlarson

@SethMichaelLarson I think it's not loading because VirtualBox.app on macOS is shipped only with VBoxPython2_6.so and VBoxPython2_7.so. That's likely because macOS does not ship Python 3 at all. You need to somehow compile VBoxPython for your Python first before you can use the bindings.

Kentzo avatar Oct 19 '18 20:10 Kentzo

Can you guys develop something automatic way? This thing is pain. Why don't you can go for something which finds / install things itself vs we have to do it?

printdhruv avatar Oct 24 '18 21:10 printdhruv

@printdhruv Above I asked for information from you to better understand your case but you didn't reply. Could you respond to my question so I can attempt to fix your case as well?

sethmlarson avatar Oct 24 '18 21:10 sethmlarson

@printdhruv I suppose it should be possible to develop a plugin that uses C-API over XPCOM instead of VBoxPython. That it will be a pain to maintain as well.

If you have control over the deployment (what version of VirtualBox with what version of Python), you can compile VirtualBox yourself with bindings for you Python.

Kentzo avatar Oct 25 '18 23:10 Kentzo

I'm experiencing the same thing, and I'm all but certain this is a duplicate of #102, just with python 3.6 instead of 3.5.

cd /usr/lib/virtualbox/
sudo cp VBoxPython3_6m.so VBoxPython3_6.so

'fixes' the problem.

How can I poke the virtualbox devs about this? https://www.virtualbox.org/ticket/17448 looks to have no activity.

nixjdm avatar Dec 07 '18 15:12 nixjdm

@nixjdm I'm wondering the same thing. I haven't heard anything on the issue or otherwise.

sethmlarson avatar Dec 07 '18 16:12 sethmlarson

Not for Mac though: VBoxPython3_7m.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x03

franz101 avatar May 07 '19 07:05 franz101

Hm, maybe that's something to raise on the VirtualBox forums?

sethmlarson avatar May 07 '19 12:05 sethmlarson

You need to somehow compile VBoxPython for your Python first before you can use the bindings.

Any idea how to do this?

@Kentzo is right, the MacOS package comes only with the VBoxPython2_6.so and VBoxPython2_7.so versions...

nkcr avatar Jul 15 '19 11:07 nkcr

@sethmlarson how are you installing VirtualBox? As far as I can see all the latest ppa/deb install methods only install with Python 2.7 bindings incl buster (which I thought dropped python2?)

So ATM a official PPA install of VirtualBox 6.0.12 on Ubuntu 18.04 will not work with Python 3+

ciarancourtney avatar Oct 08 '19 13:10 ciarancourtney

I tried dropping VBoxPython3_6m.so from the EL8 rpm beside VBoxPython2_7.so but I still get the same error Cannot find VBoxPython module (tried: VBoxPython3_6m, VBoxPython3m, VBoxPython), even when removing the m

FYI

$ nm -D VBoxPython3_6m.so | grep PyInit
000000000001268f T PyInit_VBoxPython3_6m

ciarancourtney avatar Oct 08 '19 14:10 ciarancourtney

FYI As a workaround I created a Dockerfile to build a minimal VirtualBox from source on bionic, then you can copy the two required files to your local install.

sudo docker cp vbox-build:/VirtualBox/out/linux.amd64/release/obj/VBoxPython/VBoxPython.so /usr/lib/virtualbox/
sudo docker cp vbox-build:/VirtualBox/out/linux.amd64/release/obj/VBoxPython3_6m/VBoxPython3_6m.so /usr/lib/virtualbox/

ciarancourtney avatar Oct 18 '19 10:10 ciarancourtney

Not for Mac though: VBoxPython3_7m.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x03

did you solve this problem?

Ryuchen avatar Dec 09 '19 07:12 Ryuchen

what about you, do you solve this? @Ryuchen

HengyueLi avatar Feb 16 '20 10:02 HengyueLi

what about you, do you solve this? @Ryuchen

No, It seems we have to compiler it by ourself

Ryuchen avatar Feb 24 '20 06:02 Ryuchen

I'm getting the same error. In my case, it is caused by having multiple python versions (3.7 and 3.8). Virtualbox only finds python3.7 for some reason and not 3.8, eventhough pkg-config, python, etc all leads to 3.8.

ekorian avatar Apr 24 '20 14:04 ekorian

Has anyone been able to get it to run on MacOs? I still get the error described here.

I am just wondering that this bug has not been fixed since 2018. What is going on with these guys from Virtualbox?

hgoertz82 avatar Mar 05 '21 19:03 hgoertz82

Facing the same issue on Ubuntu 20.04. Tried

cd /usr/lib/virtualbox/
sudo cp VBoxPython3_6m.so VBoxPython3_6.so

In my case it was VBoxPython3_7m, but still, that was unable to solve the issue for me. Can anyone please help?

Edit: Don't install virtualbox from the website. Running apt install virtualbox after uninstalling what I downloaded from the website fixed everything. Best part, no more python2.7 dependency.

AlexHartford avatar Jun 11 '21 02:06 AlexHartford

Has there been any fix to this issue on macos? No matter what, virtualbox only has 2_7 .sos in Virtualbox.app/Contents/MacOS/, and cannot use virtualbox-python in python3 :(

vidhanio avatar Sep 19 '21 23:09 vidhanio

The fix isn't in this library, needs to be implemented upstream. See the link to the virtualbox forums.

sethmlarson avatar Sep 20 '21 01:09 sethmlarson

Which link are you talking about? Is it this one?

vidhanio avatar Sep 20 '21 01:09 vidhanio

darn. so looks like i wont be able to use virtualbox-python until they decide to implement py3? :/ looks like ill have to look into running a vm to dev with it then, thanks for the help!

vidhanio avatar Sep 20 '21 01:09 vidhanio

@vidhanio It's not a Python 3 issue, it's about the binaries Virtualbox ships not being aware of ABI flags. If your Python version doesn't have ABI flags it'll work fine.

sethmlarson avatar Sep 20 '21 01:09 sethmlarson

This seems to be way over my head, is it possible to have a step-by-step instruction to this?

vidhanio avatar Sep 29 '21 23:09 vidhanio

For those who still have the problem., I manage to solve it by scavenging the VBoxPython3_8.so from the Ubuntu 6.26 package. It is not in the Oracle PPA package, but somehow, you can find it in the slower ubuntu package.

Then:

sudo cp VBoxPython3_8.so /usr/lib/virtualbox/

alainpannetier avatar Nov 28 '21 16:11 alainpannetier

I have this issue on MacOS Monterey:

Exception: Cannot find VBoxPython module (tried: VBoxPython3_9, VBoxPython3, VBoxPython)

I installed VirtualBox from the Oracle site, not with homebrew. Any hints?

craigatfetch avatar Aug 06 '22 00:08 craigatfetch

Wondering 🙂

Does anyone have any insight into building the VirtualBox COM Python module on the mac? Using Python 3 this time? This seems to be the recurring issue mentioned over and over here.

I have had this line from the source code bookmarked for many years now: https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Installer/darwin/Makefile.kmk#L481

The maintainers do not seem interested in making the changes we all want here. So, with enough knowledge we can start a community supported module.

nvictor avatar Nov 16 '22 14:11 nvictor