0

Shell commands that work in interactive mode do not work when I run them as a script. For example:

#!/usr/bin/env ipython

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

#Ingest the data into a giant DataFrame
cd data/raw/

If I type the above in the interactive shell, everything is working fine. If I run the script ./myScript.py, or I just copy the code above and paste it in my interactive shell (starting at the first import), I get:

    cd data/raw/
          ^
SyntaxError: invalid syntax

I feel I'm missing something obvious here but not sure what?

ventsyv
  • 3,316
  • 3
  • 27
  • 49

1 Answers1

0

Why is your script a .sh file while you write python code ?

Try with the .ipy extension

Flo
  • 936
  • 1
  • 8
  • 19