Switching Python Virtual Environments

Asked 2 years ago, Updated 2 years ago, 126 views

I'm a beginner at Python, and I'm currently mainly learning languages.

We used anaconda 4.1.1 (Python 3.5.2) to create a Python environment.
I heard Python 3.6 is out, so I'm going to study the environment, but I don't understand it.

First, we built the Python 3.6 environment as follows:

 c:\conda create-npy36 python=3.6 anaconda
-
# conditions:
#
py36 C:\Users\(uname)\AppData\Local\Continuum\Anaconda3\envs\py36
root* C:\Users\(uname)\AppData\Local\Continuum\Anaconda3

I have a question.

1. I heard that activate py36 can switch between virtual environments, but I can't.
  Please tell me how to switch.
  メインThe main shell uses powershell.
  シェルShell switched when using the command prompt.

2. I was able to switch at the command prompt, but
The prompt changed to y(py36)c:> と.
in python 3.6 while (py36) is displayed  I can guess that it will be a virtual environment, but is it possible to set the default to Python 3.6?
 For example, update the root version to 3.6 and then
 Are you going to build 3.5.2?

3. I was looking online to switch between virtual environments, but virtualenv is also
 I heard that there is one, but how is it different from the activate command?

python python3 anaconda

2022-09-30 19:46

1 Answers

It is a known problem that Powershell cannot switch between Anaconda's virtual environment.This issue aggregates information.

As of March 2018, the following workaround is known:

Method 1

Use pscondaenvs.

conda install-not root-cpscondaenvs pscondaenvs

Method 2

Launch cmd in Powershell, activate and then return to Powershell.

(To set the default to Python 3.6) Is it to update the root version to 3.6 and then build a new 3.5.2?

Yes, the virtual environment is used for temporary changes, so if you want the default to 3.6, you can update it in the default environment.If you don't want to lose your current default environment at this time, you can copy (clone) your virtual environment.

For more information about Anaconda's virtual environment, see the official document.

Roughly speaking, the conda command integrates the virtualenv and pip commands.There is a comparison here in the official Anaconda document Virtualenv alone cannot install the package in a virtual environment (using pip).Also, to use the Anaconda Cloud package in the first place, you have to use the conda command.

Python's virtual environment tool is also called pyenv.There are several posts on our Stack Overflow comparing the three parties, so please take a look.


2022-09-30 19:46

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.