如何使用 WSL 读取 python 文件?
How to read python file using WSL?
我有一个从 python 3.7 导出的文件(python 安装在 windows 10 中,在 anaconda3 下),
我想使用 jupyter notebook 和 python 3.6.9(python 通过 WSL 安装 - Windows Linux 的子系统)读取此文件
我用过:
df = pd.read_csv(r"D:\Data\CSV_file.csv", sep = ",",header = None,engine = "python")
但是我得到一个错误:
FileNotFoundError: [Errno 2] No such file or directory:
'D:\Data\CSV_file.csv'
我尝试了 (csv,xlsx) 格式,但我遇到了同样的错误。
两个文件的路径是(/home/user_name
for python 3.6.9 and C:\Users\user_name
for python 3.7)。
如何使用 jupyter notebook 读取此文件?
您必须使用 Linux 文件路径,因为它的作用类似于 Linux OS。将 r"D:\Data\CSV_file.csv"
更改为 r"/mnt/d/Data/CSV_file.csv"
,因为 /mnt/d
等同于 D:
。
我有一个从 python 3.7 导出的文件(python 安装在 windows 10 中,在 anaconda3 下), 我想使用 jupyter notebook 和 python 3.6.9(python 通过 WSL 安装 - Windows Linux 的子系统)读取此文件 我用过:
df = pd.read_csv(r"D:\Data\CSV_file.csv", sep = ",",header = None,engine = "python")
但是我得到一个错误:
FileNotFoundError: [Errno 2] No such file or directory: 'D:\Data\CSV_file.csv'
我尝试了 (csv,xlsx) 格式,但我遇到了同样的错误。
两个文件的路径是(/home/user_name
for python 3.6.9 and C:\Users\user_name
for python 3.7)。
如何使用 jupyter notebook 读取此文件?
您必须使用 Linux 文件路径,因为它的作用类似于 Linux OS。将 r"D:\Data\CSV_file.csv"
更改为 r"/mnt/d/Data/CSV_file.csv"
,因为 /mnt/d
等同于 D:
。