I am trying to debug python files from github repository pypmu github. When I try to debug apps/pmy.py
I am getting
<code>Exception has occurred: ModuleNotFoundError
No module named 'synchrophasor'
File "D:BTPpypmusynchrophasorpmu.py", line 10, in <module>
from synchrophasor.frame import *
ModuleNotFoundError: No module named 'synchrophasor'
</code>
<code>Exception has occurred: ModuleNotFoundError
No module named 'synchrophasor'
File "D:BTPpypmusynchrophasorpmu.py", line 10, in <module>
from synchrophasor.frame import *
ModuleNotFoundError: No module named 'synchrophasor'
</code>
Exception has occurred: ModuleNotFoundError
No module named 'synchrophasor'
File "D:BTPpypmusynchrophasorpmu.py", line 10, in <module>
from synchrophasor.frame import *
ModuleNotFoundError: No module named 'synchrophasor'
How can I make sure that python interprets dependent files first before debugging the active file?
I tried changing args in .vscode/launch.json
but could not figure anything out?
4
Ensure that Python modules from dependent files are loaded correctly when debugging.
- Please check your
launch.json
to include theenv
setting to add your project root to the PYTHONPATH so that Python can find the synchrophasor module.
Here’s an example:
<code>{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug apps/pmy.py",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/apps/pmy.py", //specifies the file you want to debug
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "${workspaceFolder}" //add the workspace folder to the PYTHONPATH.
},
"justMyCode": false
}
]
}
</code>
<code>{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug apps/pmy.py",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/apps/pmy.py", //specifies the file you want to debug
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "${workspaceFolder}" //add the workspace folder to the PYTHONPATH.
},
"justMyCode": false
}
]
}
</code>
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug apps/pmy.py",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/apps/pmy.py", //specifies the file you want to debug
"console": "integratedTerminal",
"env": {
"PYTHONPATH": "${workspaceFolder}" //add the workspace folder to the PYTHONPATH.
},
"justMyCode": false
}
]
}
I assume that your project structure is as follow:
<code>pypmu/
├── apps/
│ └── pmy.py
├── synchrophasor/
│ ├── __init__.py
│ ├── frame.py
│ └── pmu.py
└── .vscode/
└── launch.json
</code>
<code>pypmu/
├── apps/
│ └── pmy.py
├── synchrophasor/
│ ├── __init__.py
│ ├── frame.py
│ └── pmu.py
└── .vscode/
└── launch.json
</code>
pypmu/
├── apps/
│ └── pmy.py
├── synchrophasor/
│ ├── __init__.py
│ ├── frame.py
│ └── pmu.py
└── .vscode/
└── launch.json
- Ensure that your import statements in pmu.py and other files are consistent with the file directory structure.
<code>from synchrophasor.frame import *
</code>
<code>from synchrophasor.frame import *
</code>
from synchrophasor.frame import *