UsageError:找不到行魔术函数`%cd..`

时间:2018-08-17 13:49:12

标签: python shell ipython jupyter-notebook cd

我得到了错误:

UsageError: Line magic function `%cd..` not found.

运行我通常通过shell命令从Jupyter Notebook运行的python代码时。 我一直在Jupiter笔记本中使用%cd%ls,但我不明白为什么我不能从shell运行它。 我都尝试过:

python test.py 

ipython test.py 

这是我代码的相关部分:

import csv
import matplotlib.pyplot as plt
 from PIL import Image
import numpy as np
import pandas as pd
import sys
import os
import IPython
   from scipy.misc import imread
import matplotlib.cbook as cbook
   if sys.version_info[0] < 3: 
    from StringIO import StringIO
   else:
    from io import StringIO

def main():
    script = sys.argv[0]
    map_name = sys.argv[1]
    callPenalty()

def callPenalty():
    %cd standalone-penalty
    os.system("octave-cli penalty.m map_bit.bmp 50 1 1 150 150")
    %cd..
main()

有人知道如何解决吗?

0 个答案:

没有答案