【发布时间】:2020-06-11 16:26:50
【问题描述】:
我使用windows WSL调试python源代码 我导入的一些模块我可以看到源代码,有些我不能,为什么我不能?
我在这里尝试找出 WSL 中安装的模块的位置:
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ansible
>>> ansible.__file__
'/home/boo/projects/ansible/lib/ansible/__init__.py'
>>> import site; site.getsitepackages()
['/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.8/dist-packages']
>>> cd
KeyboardInterrupt
>>>
我检查了 VSCODE 使用的 python 是否与安装的相同
然后我检查了 WSL:指向:python3 -> python3.8
tst@TEST:~/.local/lib/python3.8/site-packages/ansible/cli$ /bin/python3.8
Python 3.8.2 (default, Apr 27 2020, 15:53:34)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ansible
>>> ansible.__file__
'/home/tst/.local/lib/python3.8/site-packages/ansible/__init__.py'
解决方案: 设置:
justMyCode:false
在launch.json中
【问题讨论】:
-
你能在 VS Code 中导入模块吗?只是为了确认您没有使用正确的环境。
-
什么意思?
-
如果你查看状态栏,你确定你选择的环境已经安装了ansible吗?
标签: python debugging visual-studio-code windows-subsystem-for-linux