How to Create a VSCode Python Workspace?

你离开我真会死。 提交于 2019-12-22 00:15:53

问题


I'm trying to setup python on Visual Studio Code on MacOS. I have Python 2.7 and 3.5 interpreters installed on my computer. When I attempted to create my first python file the import modules were not found.

According to the various setup instructions I've seen I'm supposed to be able to configure for my interpreter in "workspace settings." But I'm not sure I have a workspace, where to find it or how it is created.

When I go to the Command Palette and try to run Python: Select Workplace Interpreter I get an error that says, "Please open a workspace to select the Python Interpreter"

When I go to Preference->Settings, the Workplace Settings tab is greyed out and inactive.

On this page, under User and Workspace Settings it says, "The workspace setting file is located under the .vscode folder in your project."

If a workspace is related to a project then how is a project created? After far as I can see, VSCode only has the menu option for File->New File, not New Project.

Where is .vscode folder? How is it created?


回答1:


VS Code workspace is the directory which was opened by VS code
You should create virtual environment and make VS Code using this virtual environment in user settings (file settings.json)
Example: Set "python.pythonPath": "${workspaceRoot}/venv/bin/python" in settings.json with venv is virtual environment directory in current workspace. Reopen VS Code



来源:https://stackoverflow.com/questions/45435268/how-to-create-a-vscode-python-workspace

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!