![]() ![]() % cd my-project/ % conda activate conda-env my-project/ ├── conda-env # Project uses an isolated env ✅ ├── data ├── src └── testsĢ️⃣ It allows you to use the same name for all of your environments (I use “conda-env”), meaning you can activate each with the same command. I prefer the approach taken by venv for two reasons.ġ️⃣ It makes it easy to tell if a project utilizes an isolated environment by including the environment as a sub-directory. % python3 -m venv /path/to/new/environmentĮnvironments created with conda, on the other hand, live by default in the envs/ folder of your Conda directory, whose path will look something like: % /Users/user-name/miniconda3/envs # Or. When you create an environment with Python’s venv module, you need to say where it lives by specifying its path. Last, you can activate your environment with the invocation: % conda activate conda-env (conda-env) % # Fancy new command promptĪnd deactivate it with: % conda deactivate % # Old familiar command prompt ⚠️ Note: It’s recommended to install all the packages you want to include in an environment at the same time to help avoid dependency conflicts. ![]() % conda create -n conda-env python=3.7 numpy=1.16.1 requests=2.19.1 You can also specify which versions of packages you’d like to install. ⚠️ Note: Because conda ensures dependencies are satisfied when installing packages, Python will be installed alongside numpy and requests □. ![]() ![]() % conda create -n conda-env numpy requests You can also install additional packages when creating an environment, like, say, numpy and requests. To specify a different version of Python, use: % conda create -n conda-env python=3.7 This environment will use the same version of Python as your current shell’s Python interpreter. From here on we’ll always use “conda-env” for the name of our environments. □ Important: Replace “conda-env” with the name of your environment. To create an environment with conda for Python development, run: % conda create -name conda-env python # Or use -n Using Conda Environments Creating Environments ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |