如何使用WSL读取python文件? [英] How to read python file using WSL?
问题描述
我有一个从 python 3.7 导出的文件(python 安装在 windows 10 中,在 anaconda3 下),我想使用 jupyter notebook 和 python 3.6.9(通过 WSL 安装的 python - Linux 的 Windows 子系统)读取这个文件我用过:
I have an exported file from python 3.7 (python installed in windows 10, under anaconda3), I want to read this file using jupyter notebook and python 3.6.9 (python installed via WSL - Windows Subsystem for Linux) I used:
df = pd.read_csv(r"D:\Data\CSV_file.csv", sep = ",",header = None,engine = "python")
但是我遇到了一个错误:
But I got an error:
FileNotFoundError: [Errno 2] 没有这样的文件或目录:'D:\Data\CSV_file.csv'
FileNotFoundError: [Errno 2] No such file or directory: 'D:\Data\CSV_file.csv'
我尝试了 (csv,xlsx) 格式,但我遇到了同样的错误.两个文件的路径是(/home/user_name
for python 3.6.9 和 C:\Users\user_name
for python 3.7).如何使用 jupyter notebook 读取此文件?
I tried (csv,xlsx) formats but I had the same error.
the paths of two files are (/home/user_name
for python 3.6.9 and C:\Users\user_name
for python 3.7).
How can I read this file using jupyter notebook?
推荐答案
您必须使用 Linux 文件路径,因为它的作用类似于 Linux 操作系统.将 r"D:\Data\CSV_file.csv"
更改为 r"/mnt/d/Data/CSV_file.csv"
自 /mnt/d
code> 等价于 D:
.
You have to use Linux file paths because it is acting like the Linux OS. Change r"D:\Data\CSV_file.csv"
to r"/mnt/d/Data/CSV_file.csv"
since /mnt/d
is equivalent of D:
.
这篇关于如何使用WSL读取python文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!