错误:线魔术功能 [英] Error: Line magic function
问题描述
我正在尝试使用python读取文件,但不断出现此错误
I'm trying to read a file using python and I keep getting this error
ERROR: Line magic function `%user_vars` not found.
我的代码只是非常基本的
My code is very basic just
names = read_csv('Combined data.csv')
names.head()
我尝试读取或打开文件时都会得到此提示.我尝试使用此线程寻求帮助.
I get this for anytime I try to read or open a file. I tried using this thread for help.
我正在使用有思想的顶篷,并且我的IPython版本是2.4.1.我确保使用 IPython安装页面进行更新以获取帮助.我不确定出什么问题了,因为打开/读取文件应该非常简单.我什至在打开文本文件时遇到此错误.
I'm using enthought canopy and I have IPython version 2.4.1. I made sure to update using the IPython installation page for help. I'm not sure what's wrong because it should be very simple to open/read files. I even get this error for opening text files.
我导入了追溯并使用了
print(traceback.format_exc())
但是我所得到的只是一无所有.我不知道那是什么意思.
But all I get is none printed. I'm not sure what that means.
推荐答案
看起来您正在使用熊猫.尝试以下操作(假设您的csv文件与脚本库位于同一路径),如果您使用的是IPython Shell,请一次将其插入一行:
Looks like you are using Pandas. Try the following (assuming your csv file is in the same path as the your script lib) and insert it one line at a time if you are using the IPython Shell:
import pandas as pd
names = pd.read_csv('Combined data.csv')
names.head()
这篇关于错误:线魔术功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!