mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 04:01:36 +01:00
python relative import
This commit is contained in:
20
rootfs_overlay/lkmc/python/relative_import/test
Executable file
20
rootfs_overlay/lkmc/python/relative_import/test
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eux
|
||||
|
||||
# myfile_user works from all directories.
|
||||
./myfile_user.py
|
||||
cd ..
|
||||
relative_import/myfile_user.py
|
||||
cd relative_import/mydir
|
||||
../myfile_user.py
|
||||
cd ..
|
||||
|
||||
# TODO any better way to run mydir/myfile_user.py?
|
||||
|
||||
# ./mydir/myfile_user.py
|
||||
#Traceback (most recent call last):
|
||||
# File "./mydir/myfile_user.py", line 3, in <module>
|
||||
# import myfile
|
||||
#ModuleNotFoundError: No module named 'myfile'
|
||||
|
||||
python -m mydir.myfile_user
|
||||
Reference in New Issue
Block a user