|
| 1 | +--- |
| 2 | +title: How to generate environment file for Python jobs |
| 3 | +slug: generate-environment |
| 4 | +excerpt: Find out how to create your Python environment and export it as an environment file. |
| 5 | +section: How to |
| 6 | +order: 4 |
| 7 | +--- |
| 8 | + |
| 9 | +**Last updated 17<sup>th</sup> April, 2020** |
| 10 | + |
| 11 | +## Objective |
| 12 | +This guide helps you create your python environment with Conda. Then we will see how to export it so you can use it to submit your Python job on OVHcloud Data Processing platform. |
| 13 | + |
| 14 | +To read an introduction about the Data Processing service you can visit [Data Processing Overview](../overview){.external}. |
| 15 | + |
| 16 | +## Requirements |
| 17 | +- Your application code as Python files. |
| 18 | +- Conda installed on your computer, refer to [this guide](https://docs.conda.io/projects/conda/en/latest/user-guide/install/). |
| 19 | + |
| 20 | +## Instructions |
| 21 | + |
| 22 | +### Step 1: Create your environment |
| 23 | + |
| 24 | +OVHcloud Data processing is using Conda in order to manage packages and their dependencies. If you haven't installed Conda yet please do. |
| 25 | + |
| 26 | +With Conda, you can create, export, list, remove, and update environments that have different versions of Python and/or packages installed in them. OVHcloud Data Processing uses this environment to make sure your Python job has everything necessary to run smoothly. If you want to learn more about Conda, have a look at [their documentation](https://docs.conda.io/en/latest/). |
| 27 | + |
| 28 | +Once installed, Conda will automatically create a first environment. You can then start installing the needed packages. To do so, use the install command: |
| 29 | +```shell-session |
| 30 | +$ conda install numpy |
| 31 | +``` |
| 32 | +It will install the latest version of Numpy in the current environment, you just have to repeat this for each needed package. You can learn more about the install command and its options [here](https://docs.conda.io/projects/conda/en/latest/commands/install.html). |
| 33 | + |
| 34 | +### Step 2: Export your environment |
| 35 | + |
| 36 | +Now that you have an environment that suits your code, it's time to export it! To do so, make sure Conda is set in the environment you want to export and run this command: |
| 37 | +```shell-session |
| 38 | +$ conda env export --from-history -f environment.yml |
| 39 | +``` |
| 40 | + |
| 41 | +It's going to generate a portable environment file. You will need this file to run your code on OVHcloud Data Processing. To learn more about environment file, have a look [here](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#sharing-an-environment). |
| 42 | + |
| 43 | +You can now move on to the next step and [submit a Python job](../submit-python). |
| 44 | + |
| 45 | +## Go further |
| 46 | + |
| 47 | +To learn more about using Data Processing and how to create cluster and process your data, we invite you to look at [Data Processing documentations page](../). |
| 48 | + |
| 49 | +You can send your questions, suggestions or feedbacks in our community of users on [https://community.ovh.com/en/](https://community.ovh.com/en/){.external} or in our public [Gitter](https://gitter.im/ovh/data-processing){.external} |
0 commit comments