1

I am running across a strange Python error on Visual Studio Code:

    comp:project mia$ python3 restapi.py
    Traceback (most recent call last):
      File "restapi.py", line 2, in <module>
        from adapters import JSONAdapter
      File "/Users/me/project/adapters.py", line 7
    """
      ^
    IndentationError: expected an indented block

Code:

from flask import Flask, jsonify, request
from adapters import JSONAdapter
from chatbot import Chatbot

Screenshot:

enter image description here

Clicking on the small red triangle shows this:

enter image description here

That's code that I have deleted now. And yes, I saved the file before executing it, and I even opened the file with another editor to make sure only those three lines were in the file.

However, I don't see an indentation issue on line 7 even with the lines with the red background.

Any clue what's going on here?

5
  • I'm so confused about what we're looking at, line 7 seems to be changing and then it looks like we're looking between line 1 and 2 Commented Jan 17, 2019 at 12:04
  • check out the line 7 in File "/Users/me/project/adapters.py" Commented Jan 17, 2019 at 12:05
  • I don't use VS-code so maybe I'm misunderstanding the debugging you're doing. Indentation is indentation, it's standard in Python, so we just need to see an accurate copy of your actual code throwing the error. Commented Jan 17, 2019 at 12:06
  • I think @prashantrana is right. The code was in another file, but I was distracted with the red triangle showing the code that I just deleted. Commented Jan 17, 2019 at 12:07
  • @multigoodverse just to check the error start from the last line in that error ,from there you have to start Commented Jan 17, 2019 at 12:09

1 Answer 1

1

So, the error was in another file. I missed that fact by looking at the Debugging dialog of VS Code which I was not used to. It made me thinking the error was in the main file. Later I looked at the plain Python error as well, but I was already convinced there was something with the main file.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.