共用方式為


Quickstart: Create a project from a Cookiecutter template

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Once you've installed Python support in Visual Studio, it's easy to create a new project from a Cookiecutter template, including many that are published to GitHub. Cookiecutter provides a graphical user interface to discover templates, input template options, and create projects and files. It's included with Visual Studio 2017 and later and can be installed separately in earlier versions of Visual Studio.

  1. For this quickstart, first install the Anaconda3 Python distribution, which includes the necessary Python packages for the Cookiecutter template shown here. Run the Visual Studio installer, select Modify, expand the options for Python development on the right side, and select Anaconda3 (either 32-bit or 64-bit). Note that installation may take some time depending on your Internet speed, but this is the simplest way to install the needed packages.

  2. Launch Visual Studio.

  3. Select File > New > From Cookiecutter. This command opens a window in Visual Studio where you can browse templates.

    New Project from Cookiecutter template

  4. Selected the Microsoft/python-sklearn-classifier-cookiecutter template, then select Next. (The process may take several minutes the first time you use a particular template, as Visual Studio installs the required Python packages.)

  5. In the next step, set a location for the new project in the Create To field, then select Create and Open Project.

    Second step using Cookiecutter, setting project properties

  6. When the process is complete, you see the message Successfully created files using template.... The project is opened in Solution Explorer automatically.

  7. Press Ctrl+F5 or select Debug > Start without Debugging to run the program.

    Output of the python-sklearn-classifier-cookiecutter template project

Next steps

See also