mbusb / multibootusb

Create multiboot live Linux on a USB disk...
http://multibootusb.org/
GNU General Public License v2.0
1.39k stars 201 forks source link

Devel branch: Error import osdriver #367

Closed malkavi closed 6 years ago

malkavi commented 6 years ago

I have compiled and installed correctly multibootusb devel branch (sudo python3 setup.py install), but I can't execute it. The osdriver.py is in the scripts folder with the other files but can't be imported. Folder: "\usr\lib\python3.4\site-packages\scripts\"

I can execute multiboot usb from source folder correctly using "kdesu python3.4 multibootusb".

Thanks for your help.

Output:

Using python version  3.4.6 (default, Mar 22 2017, 12:26:13) [GCC] on platform Linux-4.4.126-48-default-x86_64-with-SuSE-42.3-x86_64
Traceback (most recent call last):
  File "/usr/bin/multibootusb", line 37, in <module>
    from scripts import osdriver
ImportError: cannot import name 'osdriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/multibootusb", line 40, in <module>
    from .scripts.mbusb_cli import *
SystemError: Parent module '' not loaded, cannot perform relative import
shinji-s commented 6 years ago

Are 'multibootusb' in the source folder and '/usr/bin/multibootusb' the same? Please run the following code snippet outside of the source folder and tell us what you get.

import os
from scripts import config
print (config.__file__)
for x in sorted(os.listdir(os.path.dirname(config.__file__))):
  print ('* '+x)

from scripts import osdriver
print (osdriver.__file__)

@mbusb, considering installation by setup.py will place 'scripts' module directly under site-packages/ or dist-packages/, perhaps we should eventually change the module name to be more specific one (e.g. 'mbusb_scripts', 'mbusb.scripts', 'multibootusb' or 'mbusb').

malkavi commented 6 years ago

As is obvious, my fault. There was an old folder from old tests. In the Output you can see an old version folder. I have removed it and now is working.

Output of the code:

/usr/lib/python3.4/site-packages/multibootusb-9.1.0-py3.4.egg/scripts/config.py
* _7zip.py
* __init__.py
* __pycache__
* admin.py
* config.py
* debug.py
* distro.py
* gen.py
* grub.py
* gui
* imager.py
* install.py
* iso.py
* isodump3.py
* mbusb_cli.py
* mbusb_gui.py
* menus.py
* persistence.py
* progressbar
* pyudev
* qemu.py
* syslinux.py
* udisks.py
* uninstall_distro.py
* update_cfg_file.py
* usb.py
Traceback (most recent call last):
  File "test.py", line 7, in <module>
    from scripts import osdriver
ImportError: cannot import name 'osdriver'

Output after removing "/usr/lib/python3.4/site-packages/multibootusb-9.1.0-py3.4.egg/":

/usr/lib/python3.4/site-packages/scripts/config.py
* _7zip.py
* __init__.py
* __pycache__
* admin.py
* config.py
* debug.py
* distro.py
* gen.py
* grub.py
* gui
* imager.py
* install.py
* iso.py
* isodump3.py
* mbusb_cli.py
* mbusb_gui.py
* menus.py
* osdriver.py
* param_rewrite.py
* persistence.py
* progressbar
* pyudev
* qemu.py
* syslinux.py
* udisks.py
* uninstall_distro.py
* update_cfg_file.py
* usb.py
/usr/lib/python3.4/site-packages/scripts/osdriver.py

But now the scripts folder is outside folder "/usr/lib/python3.4/site-packages/multibootusb-9.2.0-py3.4.egg"

mbusb commented 6 years ago

I agree with your statement on changing the module name. This was one of my pending to do list. 'mbusb.scripts' should be the correct name.

On Wed 9 May, 2018, 7:47 PM Shinji Suzuki, notifications@github.com wrote:

Are 'multibootusb' in the source folder and '/usr/bin/multibootusb' the same? Please run the following code snippet outside of the source folder and tell us what you get.

import os from scripts import config print (config.file) for x in sorted(os.listdir(os.path.dirname(config.file))): print ('* '+x)

from scripts import osdriver print (osdriver.file)

@mbusb https://github.com/mbusb, considering installation by setup.py will place 'scripts' module directly under site-packages/ or dist-packages/, perhaps we should eventually change the module name to be more specific one (e.g. 'mbusb_scripts', 'mbusb.scripts', 'multibootusb' or 'mbusb').

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/mbusb/multibootusb/issues/367#issuecomment-387754191, or mute the thread https://github.com/notifications/unsubscribe-auth/AEC34F2V6NZf6QxMaJpWzZ5MZBvDXUhSks5twvqQgaJpZM4T4R9y .