Pete
Pete

Reputation: 19

How to solve "IndentationError: expected an indented block" in Jupyter when importing a module?

I'm quite new to Python and Jupyter Notebook and I'm running into some issues. Yesterday, I created a "toolkit" which I named "edhec_risk_kit" and it contains all the functions which I wish to call when working on a new project. The location of the file is:

"/Users/MyName/Intro to Ptf.construction and Analysis with Python/edhec_risk_kit.py"

Now I'm trying to "import" the toolkit to be Jupyter Notebook but I get the following error message:

Traceback (most recent call last):

  File "/Users/MyName/opt/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-1-d8b39bc3a411>", line 1, in <module>
    import edhec_risk_kit as RiskKit

  File "/Users/MyName/Intro to Ptf.construction and Analysis with Python/edhec_risk_kit.py", line 123
    '''

^
IndentationError: expected an indented block

What am I doing wrong? I was able to import the "toolkit" last night but now I only get the error message

Upvotes: 1

Views: 735

Answers (2)

tianlinhe
tianlinhe

Reputation: 989

I agree with the other answer (and I upvoted it), plus notice that you need to be careful with using ''', its indentation level needs to be the same as the a normal new line of code (unlike#, which you can insert at any position)

Upvotes: 0

LeOverflow
LeOverflow

Reputation: 379

Check line 123 of your toolkit file.

  File "/Users/MyName/Intro to Ptf.construction and Analysis with Python/edhec_risk_kit.py", line 123
    '''

^
IndentationError: expected an indented block

Upvotes: 1

Related Questions