python - 每当我尝试在命令行中运行 python 脚本时出现“找不到 '__main__' 模块”错误
问题描述
这是我的批处理文件代码:
@py C:\Users\Asus\Google Drive\Lifestyle\Technicals\Programming\Python\Python Scripts\Test.py %*
@pause
或者,当我在命令行中尝试这行代码时,也会出现同样的错误:
py.exe C:\Users\Asus\Google Drive\Lifestyle\Technicals\Programming\Python\Python Scripts\Test.py
我的 Test.py 文件有:
print('Hello')
解决方案
你能试试吗
python "C:\Users\Asus\Google Drive\Lifestyle\Technicals\Programming\Python\Python Scripts\Test.py"
命令行不喜欢“”(空格)字符。从而破坏了你的命令。
您需要cd directory
在正确的目录中或执行用双引号括起来的命令
推荐阅读
- numpy - 在 Spyder 的变量资源管理器中加载整个列表
- git - 在推送到 github 之前,我是否需要 git checkout 从 svn 转换创建的远程分支
- google-maps - form.currentstate.validate() 失败 - Flutter
- ios - 在动态 UITableView 中使用多个 UIPickerView
- node.js - 在使用 node 和 puppeteer 获得页面响应后,如何找到某个是否存在?
- checkbox - 您如何防止 NVDA 将复选框读取为“未标记”?
- maven - GitHub 包:GitHub 组织的单个 Maven 存储库
- verilog - 无法理解 D 触发器代码中的错误
- c++ - unordered_map 对哈希函数的过度调用
- android - 无法在我的应用程序中集成缩放