3

So I am using vscode with conda (for a django project), and trying to activate my virtual environment named "venv". And it goes from:

(base) C:\Users\User\Desktop\pfa-master\pfa-master\venv\Scripts> .\activate

to something like this:

(venv) (base) C:\Users\User\Desktop\pfa-master\pfa-master\venv\Scripts>

And if I try to find out Python version, it shows error like this:

(venv) (base) C:\Users\User\Desktop\pfa-master\pfa-master>which python
'which' is not recognized as an internal or external command,
operable program or batch file.

Note: I have Python in environment variables for anaconda.

What am I doing wrong?

AMC
  • 2,642
  • 7
  • 13
  • 35
Hira Tanveer
  • 155
  • 1
  • 4
  • 14
  • 1
    activate is not a valid anaconda command, you should use `conda activate venv` instead – Vasilis Lemonidis Oct 05 '20 at 11:53
  • 1
    Maybe try and use the `deactivate` command to exit the virtual environments? You might need to do this twice to exit both virtual environments, and then just activate your `venv` environment separately – Jake Levi Oct 05 '20 at 11:54
  • 1
    Also if you want to know the Python installation directory on Windows, you can do it by opening a `cmd` terminal (if you're currently in a Powershell terminal you can use the command `start cmd` to do this) and use the command `where python`, this will print out all Python installation locations on your system path. If you want to just know which version of Python is currently the default, use `python --version` – Jake Levi Oct 05 '20 at 12:04
  • if you want to work in the environment you can use both,its highly encouraged to use an environment.. but i prefer without env – Mumin Oct 05 '20 at 13:41
  • If you want to prevent Conda from auto-activating, then possible duplicate: https://stackoverflow.com/q/54429210/570918 – merv Oct 07 '20 at 04:00

6 Answers6

5

You need to deactivate Conda. In terminal, conda deactivate should get rid of (base). When you want to reactivate Conda, conda activate.

ms1234
  • 51
  • 1
  • 3
2

You have two virtual environments active.

conda and virtualenv are both package manager and environment management system :

If you want to use (venv) only, you need to deactivate conda : conda deactivate

If you want to use (base) only, you need to delete the venv directory from your repository : sudo rm -rf venv. Command differs because you are using Windows.

noestl
  • 31
  • 3
1

first you can use activate to activate venv, and then use conda deactivate to deactivate (base).

0

Use the command python -V to find the installed python version and pip -V to get the current pip version.

Nico Bleiler
  • 475
  • 4
  • 14
0

if you have anaconda in your environmental PATH, try activate venv. Also, try restarting VScode sometimes it glitches.

mango orange
  • 118
  • 9
-1

Try this command:

python --version
Slava Rozhnev
  • 9,510
  • 6
  • 23
  • 39
Max
  • 1