目录
2 Creating the project's files
4 Creating our Python application
5 Updating our project with new dependencies
Creating projects
创建项目
In this tutorial, we will walk through how to set up a new Python project in conda using an environment.yml
file.
This file will help you keep track of your dependencies and share your project with others. We cover how to create your project, add a simple Python program and update it with new dependencies.
在本教程中,我们将介绍如何使用 environment.yml
文件在conda中设置一个新的Python项目。此文件将帮助您跟踪依赖项并与其他人共享您的项目。
我们将介绍如何创建您的项目,添加一个简单的Python程序并使用新的依赖项更新它。
1 Requirements
1 需求
To follow along, you will need a working conda installation. Please head over to our installation guide for instructions on how to get conda installed if you do not have it.
要遵循沿着,您将需要一个工作conda安装。如果您没有安装conda,请查看我们的安装指南,了解如何安装conda。
This tutorial relies heavily on using your computer's terminal (Command Prompt or PowerShell on Windows), so it is also important to have a working familiarity with using basic commands such as cd
and ls
.
本教程在很大程度上依赖于使用计算机的终端(Windows上的命令提示符或PowerShell),因此熟悉使用基本命令(如 cd
和 ls
)也很重要。
2 Creating the project's files
2 创建项目文件
To start off, we will need a directory that will contain the files for our project. This can be created with the following command:
首先,我们需要一个包含项目文件的目录。这可以通过以下命令创建:
mkdir my-project
In this directory, we will now create a new environment.yaml
file, which will hold the dependencies for our Python project. In your text editor (e.g. VSCode, PyCharm, vim, etc.), create this file and add the following:
在这个目录中,我们现在将创建一个新的 environment.yaml
文件,它将保存Python项目的依赖项。在你的文本编辑器中(例如VSCode,PyCharm,Vim等),创建此文件并添加以下内容:
name: my-project
channels:
- defaults
dependencies:
- python