2/26/2024 0 Comments Conda virtual environmentThere, I hope it'll help and others can tell me if they find this useful or insane. This is relatively safe as conda makes sure not to break dependencies, I would not use this with pip for example. N.B : Sometimes I want to update all the packages in all my environments (except base) I use : #!/usr/bin/env bashįor env in $(conda env list | cut -d" " -f1 | tail -n+4) do conda update -all -y -n $env done One project or one field has its own environment : I'll usually clone the dsenvironment to have all packages I need, in another environment and then add the more specific packages to that environment.ĭon't hesitate to create new environments and delete old ones, you don't want to have them rotting there. Once a package is installed in one environment, it's accessible to all others, meaning that having 5 or 20 environments doesn't change much in terms of memory taken. One project or one field needs its own environment. You can create a "default" environment or a text file with the packages you need and use those when you create a new environment, it's way less tedious than installing by hand. This env is kept up to date as much as possible and I clone it when I create new environments that will be more shortly lived. But I keep it relatively lean and don't install much other stuff. I have a data science environment called ds, in which I have all the relevant data science packages such as numpy, pandas, scipy, etc. I never touch the base environment except for updates, otherwise it should be left alone. Lastly, for environments management, I do the following, I'm not saying it's the best way to do things but it works for me. Some others are more critical like your numpy or tensorflow version, so don't forget to look at error messages and read the documentation before widly installing stuff. Some dependencies are usually of little consequence like setuptools, tqdm, a modern version will suffice. ![]() The only thing I'd warn about is using pip with conda, it's very easy to do but it means that it can break dependencies if you're not careful if you install a package with pip, try to have the dependencies installed with it too. I prefer conda-forge over the other conda channel to get my packages as it is usually more up to date. I use condaevery day to manage different environments and in tandem with jupyter, it allows me to spin up notebooks from several languages easily. I vastly prefer miniconda over the Anaconda GUI, there's like 5 commands to learn and you're good to go. With virtual environment, you get to put everything into different boxes or shelves.Ĭonda is very practical in my opinion because it is both a package manager and a virtual env manager. It's like a flat piled with different books, furniture pieces, and tools. That's a very nice way to organize all your different projects' dependencies :) Imagine having just a built-in Python and inside it is all the different packages you use for the hundreds of projects you have. You know the package exists only in this virtual environment (in that specific version). So whenever you are inside a virtual environment and you run: $ pip install package_name ![]() ![]() Z shell) with oh-my-zsh, where you can choose a theme that displays your current virtual environment.Īnd see that you're using pip not in the built-in Python shipped with your machine (such as for OS X) but pip from a virtual environment. If your terminal does not display your virtual environment (as in you cannot see `Base` when you open a new terminal), try using zsh (a.k.a. It is as easy as the following lines: $ conda create -name textbook python=3.8 So use virtual environments early on makes sure that you can flexibly maintain each of your projects.Ĭonda makes it very easy for you to use virtual environments (here's a cheat sheet). You cannot possibly maintain all of them at once if you only use your Base conda environment, because each might require a different version of Flask, Python, or some other packages. Imagine you'd have 3 web projects, each requiring a different version of Flask. Build up the habit now and you'll be a happy data scientist or developer later. It is better to start early than to start later, even if the concept of virtual environments might sound completely confusing to you.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |