formulahendry / formulahendry/vscode-code-runner
[Bug] python: package-import from an other folder above only works in terminal, not in output
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 351
- PR merge metrics
- No merged PRs in 30d
Description
- VS Code Version: 1.77.3
- OS Version: Windows 10
- Code Runner Version: v0.12.0
**Describe the bug**
Importing a python-package from an other folder **above** the current file does only works in terminal. Compiled in Output-Window, it gives a ModuleNotFoundError.
**To Reproduce**
1. workspace-folder structure:
- test_package_import
- .venv
- .vscode
- package
- \_\_init\_\_.py
- inner_package.py
- projects
- inner_project_main.py
- main.py
2. define a function "func" in inner_package.py
3. in main.py, write
`from package.inner_package import func`
4. in inner_project_main.py
`from package.inner_package import func`
**Actual behavior**
In main.py the statement works in both, terminal and output (using "code-runner.runInTerminal": true or false to switch). But for the inner_project_main.py it only works in terminal. When I run it in output, I got an ModuleNotFoundError: No module named 'package'.
**Expected behavior**
Should work identically in both files (like e.g. in PyCharm)
**More Backround**
I have tried everything from https://stackoverflow.com/questions/50966876/vs-code-code-runner-doesnt-work-with-virtualenvs, but nothing worked for me.
Neither
"code-runner.executorMap": {
"python": "$pythonPath $fullFileName"
},
or
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName"
},
don't change the behaviour.
Or is there anything I have missunderstood? It would by fantastic if that could be fixed (due to better Highlithing in the Output). Thank you very much!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.