我正在尝试从 shell 执行一个简单的
hello.py
.py
import os os.getcwd()
错误总是如下:
NameError:名称'hello.py'未定义。
有什么建议吗?
我尝试了很多可能的解决方案,但没有一个有效。 例如我尝试编写 python3 hello.py 但没有成功。 在此输入图片描述
所以基本上Python已经安装在WSL中了。如果你在 Windows 文件夹中有一个 hello.py,即
C:/Users/<user>/Desktop/hello.py
那么你需要知道 wsl 有不同的文件夹结构。如果您想从 Windows 访问该文件,则其路径从
/mnt/c/Users/<user>/Desktop/hello.py
假设你走在正确的道路上,尝试跑步
python3 ./hello.py
或
python ./hello.py
我希望你觉得这有帮助