question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugging no longer adds the root folder to PYTHON_PATH

See original GitHub issue

Environment data

  • VS Code version: Version: 1.29.0 (user setup) Commit: 5f24c93878bd4bc645a4a17c620e2487b11005f9 Date: 2018-11-12T07:47:15.448Z Electron: 2.0.12 Chrome: 61.0.3163.100 Node.js: 8.9.3 V8: 6.1.534.41 Architecture: x64
  • Extension version (available under the Extensions sidebar): 2018.10.1
  • OS and version: Windows 10 enterprise
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.5 64 bit with Anaconda
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Relevant/affected Python packages and their versions: ----

Actual behavior

When debugging from outside of the root folder. imports from the root folder no longer work. Selecting the text, and doing shift+Enter to execute within a python console work as expected (“python.execSelectionInTerminal”)

Expected behavior

I should be able to import package from inside my root folder, even if I start debugging from files in a subdirectory of my root folder.

This behavior was working beofre updating the current version of vscode and python

Steps to reproduce:

  1. clone https://github.com/AlexandreOuellet/vscode-import-bug and open the folder in vscode
  2. open the file tests/test_some_test.py
  3. Debug this file (through F5)

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

Starting Jedi Python language engine.
##########Linting Output - pylint##########

--------------------------------------------------------------------

Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)



##########Linting Output - pylint##########

--------------------------------------------------------------------

Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)


Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

3reactions
DonJayamannecommented, Nov 14, 2018
0reactions
romelgomezcommented, Nov 14, 2018

I just create a simple python project, with last update version of visual studio code, using also last version of the plugin [2018.10.1 (09 Nov 2018)], and getting this error:

Exception has occurred: ModuleNotFoundError
No module named 'functions'

And each folder I have the __init__.py file

functions
    utils
        logger.py
        __init__.py
    __init__.py
    program.py

program.py

from functions.utils.logger import logger
logger.info('Simple Test')

logger.py

import logging
FORMAT = '[%(asctime)s] [%(levelname)s] >>> %(message)s'
logging.basicConfig( format=FORMAT )
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)

screenshot from 2018-11-14 12-39-37 screenshot from 2018-11-14 12-39-12

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set the root directory for Visual Studio Code Python ...
Go to File > Preferences > Settings, search for pythonpath. Under the Pylance options you should see Extra Paths, this is where you...
Read more >
PYTHONPATH not handled correctly by Run/Debug ...
Pycharm's run and debug environment isn't updating the PYTHONPATH to include the content roots and source roots. I have to uncheck and check...
Read more >
Source Path (Debugging with GDB) - sourceware.org
If a compilation directory is recorded in the debug information, and GDB has not found the source file after the first search using...
Read more >
The Module Search Path - Real Python
In this video, you're going to explore the module search path. So, where can you import a module from? When the interpreter executes...
Read more >
Debugging configurations for Python apps in Visual Studio Code
vscode folder in your workspace. Note: To change debugging configuration, your code must be stored in a folder. To initialize debug configurations, first...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found