virtualbox-python
virtualbox-python copied to clipboard
Exception: Cannot find VBoxPython module (tried: VBoxPython3_6, VBoxPython3, VBoxPython)
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)
This might be a good place to start as this issue seems related: https://github.com/SethMichaelLarson/virtualbox-python/issues/102
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?
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.
@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.
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 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?
@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.
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 I'm wondering the same thing. I haven't heard anything on the issue or otherwise.
Not for Mac though: VBoxPython3_7m.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x03
Hm, maybe that's something to raise on the VirtualBox forums?
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...
@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+
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
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/
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?
what about you, do you solve this? @Ryuchen
what about you, do you solve this? @Ryuchen
No, It seems we have to compiler it by ourself
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.
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?
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.
Has there been any fix to this issue on macos? No matter what, virtualbox only has 2_7 .so
s in Virtualbox.app/Contents/MacOS/
, and cannot use virtualbox-python in python3 :(
The fix isn't in this library, needs to be implemented upstream. See the link to the virtualbox forums.
Which link are you talking about? Is it this one?
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 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.
This seems to be way over my head, is it possible to have a step-by-step instruction to this?
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/
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?
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.