【发布时间】:2016-11-16 20:40:15
【问题描述】:
我是 Python 的新手。我下载了一个 csv 文件来使用。我在 Windows 8.1 上使用 Python 2.7 中的 Anaconda 包。我可以完美地在 Spyder 中打开和读取文件,但是当我尝试在 iPython shell 中打开它时,我收到以下错误消息:
[Errno 2] No such file or directory: 'C:/Users/User/Desktop/Python stuff/Data.csv
我的代码 -
DSI_data = open('C:/Users/User/Desktop/Python stuff/Data.csv')
DSI_reader = (pd.read_csv(DSI_data), ',')
print DSI_reader
输出:
IOError Traceback (most recent call last)
<ipython-input-2-14a014f3c776> in <module>()
1
----> 2 DSI_data = open(''C:/Users/User/Desktop/Python stuff/Data.csv')
3
4 DSI_reader = (pd.read_csv(DSI_data), ',')
5
IOError: [Errno 2] No such file or directory: 'C:/Users/User/Desktop/Python stuff/Data.csv'
我想在 Spyder 中打开这个文件,但 iPython 没有找到它。另外,我需要知道如何打开这个iniPython
【问题讨论】:
-
请显示minimal reproducible example。换句话说,你运行的实际代码
-
错误信息表示您尝试打开文件的位置不存在。
-
为什么错误信息中有两个左引号?
-
该错误非常具有描述性,并告诉您在该位置没有具有该名称的文件。您确定
Data.csv存在于该目录中吗?好久没用Windows了,但是Windows路径不使用`\`(“反斜杠”)吗? -
如果没有,Spyder 如何评估文件?好奇,我还是 Python 新手。
标签: python python-2.7 csv ipython spyder