简体   繁体   中英

How can I create a Visual Studio Code Python workspace?

I'm trying to set up 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 menu FilePreferenceSettings , 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, Visual Studio Code only has the menu option for menu FileNew File , not New Project .

Where is the .vscode folder? How is it created?

A Visual Studio Code workspace is the directory which was opened by Visual Studio Code.

You should create a virtual environment and make Visual Studio 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 the virtual environment directory in the current workspace. Reopen Visual Studio Code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM