I am trying to run a python script located at a different directory using a soft link. Here is what I have done -
This is the main script calling other scripts located in all_tests folder -
import os
import sys
import time
modules_path = os.path.dirname(os.path.realpath(sys.argv[0])) + "/all_tests"
sys.path.append(modules_path)
import getScriptsReady #located in all_tests
import create_my_test_1 #located in all_tests
# get current paths
saved_path = os.getcwd()
realpath = os.path.dirname(os.path.realpath(sys.argv[0]))
print("Current Directory: " + saved_path)
print("Path to main.py: ", realpath)
print("Path to Sub-Script Directory: ", modules_path)
Here is the file hierarchy I am using -
.
├──template
│ ├──refr
│ │ ├──bin
│ │ │ ├──main.py
│ │ │ ├──all_tests
│ │ │ │ ├── getScriptsReady.py
│ │ │ │ ├── create_my_tests.py
|
├──sim
├──tests
I am trying to run from tests directory using - ../refr/bin/main.py but am getting the error -
File "../refr/bin/main.py", line 8, in <module>
import getScriptsReady
ModuleNotFoundError: No module named 'getScriptsReady'