I have a requirements.yaml file and I want to create a python virtual environment using it. The file looks like this
dependencies:
- python=3.7.5
- pip=19.3.1
- pip:
- jupyter==1.0.0
- pandas==1.0.0
- scikit-learn==0.22.1
- numpy==1.18.1
- matplotlib==3.1.3
- seaborn==0.10.0
- black==19.10b0
- haversine==2.2.0
- toml==0.10.0
- nose==1.3.7
How can I use this file to create a new environment?
this looks like a conda environment (i could be wrong). In this case (if you have conda) you can do the following:
conda env create --name environment_name -f environment.yml
https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf
If you dont have or want Conda you would need to convert it to a requirements.txt
- pip:
- jupyter==1.0.0
- pandas==1.0.0
- scikit-learn==0.22.1
will look like that in the requirements.txt:
jupyter==1.0.0
pandas==1.0.0
scikit-learn==0.22.1
and then create and switch to your virtual environment
https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/26/python-virtual-env/
and then do
pip install -r requirements.txt
In case you are using conda your env.yml should look like
name: my_env
channels:
- defaults
dependencies:
- python=3.7.5
- pip=19.3.1
- pip:
- jupyter==1.0.0
- pandas==1.0.0
- scikit-learn==0.22.1
- numpy==1.18.1
- matplotlib==3.1.3
- seaborn==0.10.0
- black==19.10b0
- haversine==2.2.0
- toml==0.10.0
- nose==1.3.7
and in order to load it you need to run the following from the terminal.
conda env create -f env.yml
Few more suggestions.
conda env export | grep -v "^prefix: " > env.yml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With