Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

import_vboxapi contextmanager fails to find pywin32 packages if python not installed in C:\PythonXX #36

Closed
cwalv opened this issue May 28, 2015 · 1 comment

Comments

@cwalv
Copy link

cwalv commented May 28, 2015

Python isn't installed in C:\pythonXX on my system, so the extra packages defined on line 40 are not found, and ImportError is re-raised at line 71 even tho all the necessary packages are installed. Calling virtualbox.VirtualBox() again does not throw the exception because 'C:\\Program Files\\Oracle\\VirtualBox\\sdk\\install' is added to the path on the first call.

In [2]:

import virtualbox
In [3]:

vbapi = virtualbox.VirtualBox()
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-3-eb9fceae80cf> in <module>()
----> 1 vbapi = virtualbox.VirtualBox()

C:\Python27\ipythonenv\lib\site-packages\virtualbox\library_ext\vbox.pyc in __init__(self, interface, manager)
     15             self._i = manager.get_virtualbox()._i
     16         else:
---> 17             manager = virtualbox.Manager()
     18             self._i = manager.get_virtualbox()._i
     19 

C:\Python27\ipythonenv\lib\site-packages\virtualbox\__init__.pyc in __init__(self, mtype, mparams)
    101             raise RuntimeError("Can not create a new manager following a system exit.")
    102         if pid not in _managers:
--> 103             with import_vboxapi() as vboxapi:
    104                 self.manager = vboxapi.VirtualBoxManager(mtype, mparams)
    105 

C:\Python27\ArcGIS10.1\Lib\contextlib.pyc in __enter__(self)
     15     def __enter__(self):
     16         try:
---> 17             return self.gen.next()
     18         except StopIteration:
     19             raise RuntimeError("generator didn't yield")

C:\Python27\ipythonenv\lib\site-packages\virtualbox\__init__.pyc in import_vboxapi()
     32     """
     33     try:
---> 34         import vboxapi
     35     except ImportError:
     36         system = platform.system()

ImportError: No module named vboxapi

In [4]:

vbapi = virtualbox.VirtualBox()
@sethmlarson
Copy link
Owner

sethmlarson commented May 12, 2017

I have an idea about this that would help on all platforms where Python is installed in non-standard locations. See #67

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants