虽然我可以从终端调试我的项目,但当我尝试从visual studio代码调试时出现此错误:
File "/home/chris/.virtualenvs/floodsam/lib/python3.5/site-packages/django/contrib/gis/gdal/libgdal.py", line 43, in <module>
% '", "'.join(lib_names)
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0", "gdal1.11.0", "gdal1.10.0", "gdal1.9.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
sh-4.3$
这是我的launch.json
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"pythonPath": "${config:python.pythonPath}",
"args": [
"runserver",
"--noreload",
"--nothreading"
],
"debugOptions": [
"RedirectOutput",
"Django"
]
},
这些是我的visual studio代码项目设置:
{
"python.venvPath": "~/.virtualenvs",
"python.pythonPath": "~/.virtualenvs/floodsam/bin/python3",
"workbench.colorTheme": "Monokai",
"python.autoComplete.addBrackets": true,
"editor.minimap.enabled": true,
"python.venvFolders": [
"envs",
".pyenv",
".virtualenvs",
".direnv"
]
}
正如我所说,项目从命令行运行:
(floodsam) chris@chris-Lenovo ~/D/w/floodsam> ./manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
June 10, 2018 - 06:43:32
Django version 2.0.6, using settings 'floodsam.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
我做错了什么?