Python: ModuleNotFoundError: No module named 'mypython_folder.mypython_script'
after import the sys
@py import sys
sys.path
Python list: ['~/.julia/packages/PythonCall/XgP8G/python', '~/.julia/environments/v1.8/.CondaPkg/env/lib/python310.zip', '~/.julia/environments/v1.8/.CondaPkg/env/lib/python3.10', '~/.julia/environments/v1.8/.CondaPkg/env/lib/python3.10/lib-dynload', '~/.julia/environments/v1.8/.CondaPkg/env/lib/python3.10/site-packages',
'~/百度云同步盘/StudyResearch/AIforLS/Dermatology/code'] # this is the folder/module where all the python files located
In the python interpreter, the current directory . is in the path by default. When calling from Julia you need to add the directory to sys.path explicitly.
and (I think) similarly for PythonCall where you would do
pyimport("sys").path.append(pwd())
(And, of course, you need to do this in python as as well as soon as you want to run code that is not in the current directory or the regular path.)
Thank you for your informative answer,
yeah, I also tried to
@py import sys
sys.path.append(mypythonfolder)
sys.path
Python list: ['~/.julia/packages/PythonCall/XgP8G/python',
'~/.julia/environments/v1.8/.CondaPkg/env/lib/python310.zip', '~/.julia/environments/v1.8/.CondaPkg/env/lib/python3.10', '~/.julia/environments/v1.8/.CondaPkg/env/lib/python3.10/lib-dynload', '~/.julia/environments/v1.8/.CondaPkg/env/lib/python3.10/site-packages',
'~/百度云同步盘/StudyResearch/AIforLS/Dermatology/code'] <=# this is the folder/module where all the python files located**
but when I tried to access the pythonscript.py in that folder
it will spit:
@py import code
code.anonymize_mrxs
ERROR: Python: AttributeError: module 'code' has no attribute 'anonymize_mrxs'