暂无分类
暂无标签
发布于2020-11-09 19:37 阅读(361) 评论(0) 点赞(22) 收藏(1)
0
1
2
3
4
在使用vscode运行Python过程中,经常需要导入自己曾经写过的函数,以此简化程序。然而,在vscode中导入自己的py文件模块时,可能会存在一些问题,如这样:
ModuleNotFoundError: No module named 'test04'
这可能是你vscode中Python的读入模块读入路径存在问题,具体的解决方式有三种
import sys,os
# sys.path.append('需要作为模块引入的路径')
# 添加当前路径的前一级文件作为源文件夹
path = os.path.dirname(os.path.dirname(__file__))
print(path)
sys.path.append(path)
"python.autoComplete.extraPaths": ["./你导入模块所在目录1", "./目录2",......]
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"env": {"PYTHONPATH":"${workspaceRoot}"},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
原文链接:https://blog.csdn.net/hqs_09/article/details/109523930
0
1
2
3
4
5
6
作者:天青色等烟雨
链接: https://www.pythonheidong.com/blog/article/612043/08d5fcdd9f9f12e67ec8/
来源: python黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
Copyright © 2018-2019 python黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-1
投诉与举报,广告合作请联系z452as@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!