vscode版本:1.21.1
python版本:2.7.14
Launch.json:
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceFolder}",
"env": {},
"envFile": "${workspaceFolder}/.env",
"debugOptions": [
"RedirectOutput"
]
},
工作区设置:
"python.pythonPath": "D:\\Projects\\Python_Test\\venv\\Scripts\\python.exe",
或
"python.pythonPath": "${workspaceFolder}\\venv\\Scripts\\python.exe",
两个都失败了:
Traceback (most recent call last):
File "C:\Users\summy\.vscode\extensions\ms-python.python-2018.2.1\pythonFiles\PythonTools\visualstudio_py_launcher_nodebug.py", line 10, in <module>
import socket
File "C:\Python27\Lib\socket.py", line 47, in <module>
import _socket
ImportError: No module named _socket
在Venv中,Intergrate Terninal安装瓶失败了:
(venv) PS D:\Projects\Python_Test> pip install flask
Traceback (most recent call last):
File "C:\Python27\Lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\Lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "D:\Projects\Python_Test\venv\Scripts\pip.exe\__main__.py", line 5, in <module>
File "d:\projects\python_test\venv\lib\site-packages\pip\__init__.py", line 21, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "d:\projects\python_test\venv\lib\site-packages\pip\_vendor\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "d:\projects\python_test\venv\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 7, in <module>
from socket import error as SocketError, timeout as SocketTimeout
File "C:\Python27\Lib\socket.py", line 47, in <module>
import _socket
ImportError: No module named _socket
如果我在&#34; C:\ Python27 \ python.exe&#34;中使用解释器,它可以正常工作。
但是我发现了一个问题here,但是当我通过下载zip成功安装最新的vscode-python时,使用了码数cmd,无法工作。
win cmd中一切正常。
有什么建议吗?
['', 'C:\\other-folders-on-the-path',
'C:\\Python27',
'C:\\Python27\\Lib',
'C:\\Python27\\Scripts',
'D:\\Projects\\Python_Test',
'C:\\Windows\\SYSTEM32\\python27.zip',
'D:\\Projects\\Python_Test\\venv\\DLLs',
'D:\\Projects\\Python_Test\\venv\\lib',
'D:\\Projects\\Python_Test\\venv\\lib\\plat-win'
'D:\\Projects\\Python_Test\\venv\\lib\\lib-tk',
'D:\\Projects\\Python_Test\\venv\\Scripts',
'D:\\Projects\\Python_Test\\venv',
'D:\\Projects\\Python_Test\\venv\\lib\\site-packages']